0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2025-12-24 12:02:48 +00:00

updated test

This commit is contained in:
Víctor Losada Hernández
2024-10-03 09:01:12 +02:00
parent 3c3b4d8466
commit 6adac74f76

View File

@@ -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' });
});
});
});