Skip to content

Commit

Permalink
fix: 🐛 remove findAllUsers
Browse files Browse the repository at this point in the history
  • Loading branch information
zhumeisongsong committed Nov 14, 2024
1 parent 122ec12 commit 29547f2
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 29 deletions.
11 changes: 0 additions & 11 deletions libs/user/domain/src/lib/user.repository.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ class MockUserRepository implements UserRepository {
async findById(id: string): Promise<User | null> {
return this.users.find((user) => user.id === id) || null;
}

async findAll(): Promise<User[]> {
return this.users;
}
}

describe('UserRepository', () => {
Expand All @@ -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' },
]);
});
});
1 change: 0 additions & 1 deletion libs/user/domain/src/lib/user.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@ import { User } from './user.entity';

export interface UserRepository {
findById(id: string): Promise<User | null>;
findAll(): Promise<User[]>;
}
13 changes: 0 additions & 13 deletions libs/user/usecase/src/lib/get-user.usecase.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ describe('GetUserUsecase', () => {
beforeEach(() => {
userRepository = {
findById: jest.fn(),
findAll: jest.fn(),
} as unknown as jest.Mocked<UserRepository>;

getUserUsecase = new GetUserUsecase(userRepository);
Expand All @@ -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();
});
});
});
4 changes: 0 additions & 4 deletions libs/user/usecase/src/lib/get-user.usecase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,4 @@ export class GetUserUsecase {
async execute(id: string): Promise<User | null> {
return this.userRepository.findById(id);
}

async executeAll(): Promise<User[]> {
return this.userRepository.findAll();
}
}

0 comments on commit 29547f2

Please sign in to comment.