From 43f508addd4f442bc5729708708ec23aba57c6bf Mon Sep 17 00:00:00 2001 From: Peter Macdonald Date: Fri, 26 Jul 2024 19:09:51 +0200 Subject: [PATCH] Fixes #39, enables the validation on the feedback submission route Signed-off-by: Peter Macdonald --- .../src/service/router.test.ts | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/plugins/open-feedback-backend/src/service/router.test.ts b/plugins/open-feedback-backend/src/service/router.test.ts index 1bd3054..0481249 100644 --- a/plugins/open-feedback-backend/src/service/router.test.ts +++ b/plugins/open-feedback-backend/src/service/router.test.ts @@ -51,7 +51,9 @@ describe('createRouter', () => { userRef: 'user1', }; - (mockDatabaseHandler.addFeedback as jest.Mock).mockResolvedValueOnce(undefined); + (mockDatabaseHandler.addFeedback as jest.Mock).mockResolvedValueOnce( + undefined, + ); const response = await request(app) .post('/feedback/submit') @@ -71,7 +73,9 @@ describe('createRouter', () => { const feedbackList = [ { rating: 5, url: 'test-url', comment: 'Great!', userRef: 'user1' }, ]; - (mockDatabaseHandler.getFeedback as jest.Mock).mockResolvedValueOnce(feedbackList); + (mockDatabaseHandler.getFeedback as jest.Mock).mockResolvedValueOnce( + feedbackList, + ); const response = await request(app).get('/feedback'); @@ -84,7 +88,9 @@ describe('createRouter', () => { describe('DELETE /feedback/:id', () => { it('returns ok when feedback is removed', async () => { const feedbackId = 1; - (mockDatabaseHandler.removeFeedback as jest.Mock).mockResolvedValueOnce(undefined); + (mockDatabaseHandler.removeFeedback as jest.Mock).mockResolvedValueOnce( + undefined, + ); const response = await request(app).delete(`/feedback/${feedbackId}`); @@ -93,7 +99,9 @@ describe('createRouter', () => { status: 'ok', message: 'Feedback removed', }); - expect(mockDatabaseHandler.removeFeedback).toHaveBeenCalledWith(feedbackId); + expect(mockDatabaseHandler.removeFeedback).toHaveBeenCalledWith( + feedbackId, + ); }); }); });