Skip to content

Commit

Permalink
Fixes #39, enables the validation on the feedback submission route
Browse files Browse the repository at this point in the history
Signed-off-by: Peter Macdonald <[email protected]>
  • Loading branch information
Parsifal-M committed Jul 26, 2024
1 parent d56198d commit 43f508a
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions plugins/open-feedback-backend/src/service/router.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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');

Expand All @@ -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}`);

Expand All @@ -93,7 +99,9 @@ describe('createRouter', () => {
status: 'ok',
message: 'Feedback removed',
});
expect(mockDatabaseHandler.removeFeedback).toHaveBeenCalledWith(feedbackId);
expect(mockDatabaseHandler.removeFeedback).toHaveBeenCalledWith(
feedbackId,
);
});
});
});

0 comments on commit 43f508a

Please sign in to comment.