Skip to content

Commit

Permalink
fix: adjust test mocks
Browse files Browse the repository at this point in the history
  • Loading branch information
sanriodev committed Oct 24, 2024
1 parent 3a190bb commit 01bcb44
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ describe('SomeoneOnceSaidService', () => {
phrase: 'Test quote',
username: 'testUser',
secName: 'Teschter',
serverId: 'someid',
createdAt: mockDate,
};
const mockQuoteDocument: SomeoneOnceSaidDocument = {
Expand Down Expand Up @@ -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'));
Expand All @@ -74,7 +76,6 @@ describe('SomeoneOnceSaidService', () => {
});
});


describe('getRandomQuote', () => {
it('should return a random quote', async () => {
(modelMock as any).findOne = jest.fn((p) => ({
Expand All @@ -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();
Expand All @@ -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();
});
Expand Down

0 comments on commit 01bcb44

Please sign in to comment.