From 01bcb44ca8496d36420b0a4e50277dfe3bc95251 Mon Sep 17 00:00:00 2001 From: Matteo Juen Date: Thu, 24 Oct 2024 21:49:34 +0200 Subject: [PATCH] fix: adjust test mocks --- .../service/someone-once-said.service.spec.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/modules/models/someone-once-said/service/someone-once-said.service.spec.ts b/src/modules/models/someone-once-said/service/someone-once-said.service.spec.ts index 3bc98dd..7cbcbf9 100644 --- a/src/modules/models/someone-once-said/service/someone-once-said.service.spec.ts +++ b/src/modules/models/someone-once-said/service/someone-once-said.service.spec.ts @@ -14,6 +14,7 @@ describe('SomeoneOnceSaidService', () => { phrase: 'Test quote', username: 'testUser', secName: 'Teschter', + serverId: 'someid', createdAt: mockDate, }; const mockQuoteDocument: SomeoneOnceSaidDocument = { @@ -64,6 +65,7 @@ describe('SomeoneOnceSaidService', () => { const mockQuoteDto: SomeoneOnceSaidEntity = { phrase: 'Test quote', username: 'testUser', + serverId: 'someid', createdAt: mockDate, }; (modelMock as any).create = jest.fn((p) => new Error('Test error')); @@ -74,7 +76,6 @@ describe('SomeoneOnceSaidService', () => { }); }); - describe('getRandomQuote', () => { it('should return a random quote', async () => { (modelMock as any).findOne = jest.fn((p) => ({ @@ -85,7 +86,7 @@ describe('SomeoneOnceSaidService', () => { const countSpy = jest.spyOn(modelMock, 'countDocuments'); const findOneSpy = jest.spyOn(modelMock, 'findOne'); - const result = await service.getRandomQuote(); + const result = await service.getRandomQuote('someid'); expect(result).toStrictEqual(mockQuoteDocument); expect(countSpy).toHaveBeenCalled(); @@ -97,7 +98,7 @@ describe('SomeoneOnceSaidService', () => { (p) => new Error('Test error'), ); - const result = await service.getRandomQuote(); + const result = await service.getRandomQuote('someid'); expect(result).toBeNull(); });