Skip to content

Commit

Permalink
Fix tests (fr this time)
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanlaj committed Apr 7, 2024
1 parent e695374 commit d942c12
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion server/__tests__/controllers/attempts.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jest.mock('../../src/middleware/verifyAccess', () => ({
jest.mock('../../src/services/attemptService', () => ({
AttemptService: {
checkIsCorrect: jest.fn(),
canMakeAttempts: jest.fn().mockResolvedValue(true),
canMakeAttempts: jest.fn(),
},
}))

Expand Down Expand Up @@ -70,6 +70,9 @@ beforeEach(async () => {

describe('POST /attempts/:challengeId', () => {
it('should require access token', async () => {
jest.mocked(AttemptService.canMakeAttempts).mockResolvedValue(true);
jest.mocked(AttemptService.checkIsCorrect).mockResolvedValue(true);

const response = await request(app).post('/attempts/1');

expect(verifyAccess).toHaveBeenCalled();
Expand All @@ -84,6 +87,7 @@ describe('POST /attempts/:challengeId', () => {
} as Challenge);

jest.mocked(AttemptService.checkIsCorrect).mockResolvedValue(true);
jest.mocked(AttemptService.canMakeAttempts).mockResolvedValue(true);

await request(app).post('/attempts/1');

Expand Down Expand Up @@ -131,6 +135,7 @@ describe('POST /attempts/:challengeId', () => {
} as Challenge);

jest.mocked(AttemptService.checkIsCorrect).mockResolvedValue(true);
jest.mocked(AttemptService.canMakeAttempts).mockResolvedValue(true);

await request(app).post('/attempts/1');

Expand All @@ -145,6 +150,7 @@ describe('POST /attempts/:challengeId', () => {
} as Challenge);

jest.mocked(AttemptService.checkIsCorrect).mockResolvedValue(true);
jest.mocked(AttemptService.canMakeAttempts).mockResolvedValue(true);

await request(app).post('/attempts/1');

Expand Down

0 comments on commit d942c12

Please sign in to comment.