From 6adac74f762a2fe6b6eef73cb5a8c4bd16907b3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Losada=20Hern=C3=A1ndez?= Date: Thu, 3 Oct 2024 09:01:12 +0200 Subject: [PATCH] updated test --- server/admin.api.spec.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/server/admin.api.spec.js b/server/admin.api.spec.js index 7fa16d178..c519b032b 100644 --- a/server/admin.api.spec.js +++ b/server/admin.api.spec.js @@ -62,11 +62,11 @@ describe('Tests for admin api', ()=>{ it('should delete a notification based on its dismiss key', async () => { const dismissKey = 'testKey'; - // Mock the deleteOne function to simulate a successful deletion - jest.spyOn(NotificationModel, 'deleteOne') - .mockImplementationOnce((query) => { - expect(query).toEqual({ dismissKey }); // Ensure the correct query is passed - return Promise.resolve({ deletedCount: 1 }); + // Mock findOneAndDelete to simulate a successful deletion + jest.spyOn(NotificationModel, 'deleteNotification') + .mockImplementationOnce(async (key) => { + expect(key).toBe(dismissKey); // Ensure the correct key is passed + return { dismissKey }; // Simulate the notification object that was deleted }); const response = await app @@ -77,5 +77,6 @@ describe('Tests for admin api', ()=>{ expect(response.body).toEqual({ message: 'Notification deleted successfully' }); }); + }); });