From d942c120aa8ea3e4e5bb1bd407f5f662908f0089 Mon Sep 17 00:00:00 2001 From: Ethan Lajeunesse Date: Sun, 7 Apr 2024 17:22:36 -0400 Subject: [PATCH] Fix tests (fr this time) --- server/__tests__/controllers/attempts.test.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/server/__tests__/controllers/attempts.test.ts b/server/__tests__/controllers/attempts.test.ts index 822b7ff..80b63a3 100644 --- a/server/__tests__/controllers/attempts.test.ts +++ b/server/__tests__/controllers/attempts.test.ts @@ -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(), }, })) @@ -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(); @@ -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'); @@ -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'); @@ -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');