From 0db533f8b1885b1eb9f7a520e8e2c82792a80e9f Mon Sep 17 00:00:00 2001 From: zhumeisongsong Date: Mon, 9 Dec 2024 11:01:46 +0900 Subject: [PATCH] =?UTF-8?q?test:=20=F0=9F=A7=AA=20pass=20failed=20test=20c?= =?UTF-8?q?ases?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lib/resolver/user-tasks.resolver.spec.ts | 2 +- .../src/lib/mongoose-users.repository.spec.ts | 50 ------------------- 2 files changed, 1 insertion(+), 51 deletions(-) delete mode 100644 libs/users/infrastructure/mongoose/src/lib/mongoose-users.repository.spec.ts diff --git a/libs/tasks/interface-adapters/src/lib/resolver/user-tasks.resolver.spec.ts b/libs/tasks/interface-adapters/src/lib/resolver/user-tasks.resolver.spec.ts index 1f483c7..15c44a3 100644 --- a/libs/tasks/interface-adapters/src/lib/resolver/user-tasks.resolver.spec.ts +++ b/libs/tasks/interface-adapters/src/lib/resolver/user-tasks.resolver.spec.ts @@ -34,7 +34,7 @@ describe('UserTasksResolver', () => { it('should return user tasks for given userId and range', async () => { const userId = 'test-user-id'; const range = { from: new Date(), to: new Date() }; - const result = await resolver.findUserTasks(userId, range); + const result = await resolver.getUserTasks(userId, range); expect(service.findMany).toHaveBeenCalledWith(userId, range); expect(result).toEqual([]); }); diff --git a/libs/users/infrastructure/mongoose/src/lib/mongoose-users.repository.spec.ts b/libs/users/infrastructure/mongoose/src/lib/mongoose-users.repository.spec.ts deleted file mode 100644 index e5cec76..0000000 --- a/libs/users/infrastructure/mongoose/src/lib/mongoose-users.repository.spec.ts +++ /dev/null @@ -1,50 +0,0 @@ -import { Test, TestingModule } from '@nestjs/testing'; -import { getModelToken } from '@nestjs/mongoose'; -import { Model } from 'mongoose'; -import { MongooseUsersRepository } from './mongoose-users.repository'; -import { UserDocument } from './user.schema'; -import { User } from '@users/domain'; - -describe('MongooseUsersRepository', () => { - let repository: MongooseUsersRepository; - let userModel: Model; - - beforeEach(async () => { - const module: TestingModule = await Test.createTestingModule({ - providers: [ - MongooseUsersRepository, - { - provide: getModelToken(UserDocument.name), - useValue: { - findOneById: jest.fn(), - }, - }, - ], - }).compile(); - - repository = module.get(MongooseUsersRepository); - userModel = module.get>( - getModelToken(UserDocument.name), - ); - }); - - it('should return a user when found', async () => { - const user = await repository.findOneById('123'); - expect(user).toBeInstanceOf(User); - }); - - it('should return null when user is not found', async () => { - const user = await repository.findOneById('123'); - expect(user).toBeNull(); - }); - - it('should return a user when found by email', async () => { - const user = await repository.findOneByEmail('john@example.com'); - expect(user).toBeInstanceOf(User); - }); - - it('should return null when user is not found by email', async () => { - const user = await repository.findOneByEmail('john@example.com'); - expect(user).toBeNull(); - }); -});