Skip to content

Commit

Permalink
test: 🧪 update mock data in test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
zhumeisongsong committed Nov 25, 2024
1 parent b66a109 commit 330dca5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@ describe('GetUserUseCase', () => {

describe('execute', () => {
it('should return user when found', async () => {
const mockUser = { id: '1', name: 'John Doe' };
const mockUser = {
id: '1',
email: '[email protected]',
firstName: 'John',
lastName: 'Doe',
};
(usersRepository.findById as jest.Mock).mockResolvedValue(mockUser);

const result = await getUserUseCase.execute('1');
Expand All @@ -32,4 +37,4 @@ describe('GetUserUseCase', () => {
expect(usersRepository.findById).toHaveBeenCalledWith('1');
});
});
});
});
7 changes: 6 additions & 1 deletion libs/users/application/src/lib/users.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,12 @@ describe('UsersService', () => {

describe('findById', () => {
it('should return a user if found', async () => {
const user: User = { id: '1', name: 'John Doe' };
const user: User = {
id: '1',
email: '[email protected]',
firstName: 'John',
lastName: 'Doe',
};
jest.spyOn(getUserUseCase, 'execute').mockResolvedValue(user);

const result = await service.findById('1');
Expand Down

0 comments on commit 330dca5

Please sign in to comment.