From 29547f2f2172703817c37f342f7957110957bb6b Mon Sep 17 00:00:00 2001 From: zhumeisongsong Date: Thu, 14 Nov 2024 22:44:31 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B=20remove=20findAllUsers?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libs/user/domain/src/lib/user.repository.spec.ts | 11 ----------- libs/user/domain/src/lib/user.repository.ts | 1 - libs/user/usecase/src/lib/get-user.usecase.spec.ts | 13 ------------- libs/user/usecase/src/lib/get-user.usecase.ts | 4 ---- 4 files changed, 29 deletions(-) diff --git a/libs/user/domain/src/lib/user.repository.spec.ts b/libs/user/domain/src/lib/user.repository.spec.ts index b8d7397..f3be2c5 100644 --- a/libs/user/domain/src/lib/user.repository.spec.ts +++ b/libs/user/domain/src/lib/user.repository.spec.ts @@ -10,10 +10,6 @@ class MockUserRepository implements UserRepository { async findById(id: string): Promise { return this.users.find((user) => user.id === id) || null; } - - async findAll(): Promise { - return this.users; - } } describe('UserRepository', () => { @@ -33,11 +29,4 @@ describe('UserRepository', () => { expect(user).toBeNull(); }); - test('findAll should return all users', async () => { - const users = await userRepository.findAll(); - expect(users).toEqual([ - { id: '1', name: 'John Doe' }, - { id: '2', name: 'Jane Doe' }, - ]); - }); }); diff --git a/libs/user/domain/src/lib/user.repository.ts b/libs/user/domain/src/lib/user.repository.ts index 45e63c9..0712d58 100644 --- a/libs/user/domain/src/lib/user.repository.ts +++ b/libs/user/domain/src/lib/user.repository.ts @@ -2,5 +2,4 @@ import { User } from './user.entity'; export interface UserRepository { findById(id: string): Promise; - findAll(): Promise; } \ No newline at end of file diff --git a/libs/user/usecase/src/lib/get-user.usecase.spec.ts b/libs/user/usecase/src/lib/get-user.usecase.spec.ts index d218c9a..0b2ae94 100644 --- a/libs/user/usecase/src/lib/get-user.usecase.spec.ts +++ b/libs/user/usecase/src/lib/get-user.usecase.spec.ts @@ -8,7 +8,6 @@ describe('GetUserUsecase', () => { beforeEach(() => { userRepository = { findById: jest.fn(), - findAll: jest.fn(), } as unknown as jest.Mocked; getUserUsecase = new GetUserUsecase(userRepository); @@ -34,16 +33,4 @@ describe('GetUserUsecase', () => { expect(userRepository.findById).toHaveBeenCalledWith('1'); }); }); - - describe('executeAll', () => { - it('should return all users', async () => { - const users = [{ id: '1', name: 'John Doe' }, { id: '2', name: 'Jane Doe' }]; - userRepository.findAll.mockResolvedValue(users); - - const result = await getUserUsecase.executeAll(); - - expect(result).toEqual(users); - expect(userRepository.findAll).toHaveBeenCalled(); - }); - }); }); \ No newline at end of file diff --git a/libs/user/usecase/src/lib/get-user.usecase.ts b/libs/user/usecase/src/lib/get-user.usecase.ts index 7251b7d..9012a7f 100644 --- a/libs/user/usecase/src/lib/get-user.usecase.ts +++ b/libs/user/usecase/src/lib/get-user.usecase.ts @@ -6,8 +6,4 @@ export class GetUserUsecase { async execute(id: string): Promise { return this.userRepository.findById(id); } - - async executeAll(): Promise { - return this.userRepository.findAll(); - } }