-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathdb-signout.spec.ts
29 lines (26 loc) · 911 Bytes
/
db-signout.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import { dbSignout } from '@src/data/usecases';
import { mockSignoutRepository } from '@test-suite/data';
const makeSut = () => {
const signoutRepository = jest.fn(mockSignoutRepository());
const sut = dbSignout({ signoutRepository });
return {
sut,
signoutRepository,
};
};
describe('Signout Usecases', () => {
it('Should call signoutRepository with correct accountId', async () => {
const { sut, signoutRepository } = makeSut();
await sut('any_account_id', 'valid_accessToken');
expect(signoutRepository).toHaveBeenCalledWith(
'any_account_id',
'valid_accessToken'
);
});
it('Should throw if signoutRepository throws', async () => {
const { sut, signoutRepository } = makeSut();
signoutRepository.mockRejectedValue(new Error());
const promise = sut('any_account_id', 'valid_accessToken');
await expect(promise).rejects.toThrow();
});
});