test(06-mongoose): add missing tests for controller

This commit is contained in:
Martin Vyšňovský
2024-08-14 12:44:43 +02:00
parent 3117b241c1
commit 3c6a295037
2 changed files with 3 additions and 1 deletions

View File

@@ -7,6 +7,8 @@ import { Types } from 'mongoose';
const catsServiceMock = {
create: jest.fn(),
findAll: jest.fn(),
findOne: jest.fn(),
delete: jest.fn(),
};
describe('Cats Controller', () => {

View File

@@ -21,7 +21,7 @@ export class CatsService {
return this.catModel.findOne({ _id: id }).exec();
}
async delete(id: string) {
async delete(id: string): Promise<Cat> {
const deletedCat = await this.catModel
.findByIdAndRemove({ _id: id })
.exec();