-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(#26): ensure LoadAccountController call LoadAccount with correct…
… value
- Loading branch information
1 parent
9f329da
commit ded75e8
Showing
1 changed file
with
36 additions
and
0 deletions.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
tests/presentation/controllers/load-account-controller.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { LoadAccountController } from '@/presentation/controllers'; | ||
import { LoadAccountSpy } from '@/tests/presentation/mocks'; | ||
import MockDate from 'mockdate'; | ||
import { faker } from '@faker-js/faker'; | ||
|
||
const mockRequest = (): LoadAccountController.Request => ({ | ||
accountId: faker.datatype.uuid(), | ||
}); | ||
|
||
type SutTypes = { | ||
sut: LoadAccountController; | ||
loadAccountSpy: LoadAccountSpy; | ||
}; | ||
|
||
const makeSut = (): SutTypes => { | ||
const loadAccountSpy = new LoadAccountSpy(); | ||
const sut = new LoadAccountController(loadAccountSpy); | ||
return { sut, loadAccountSpy }; | ||
}; | ||
|
||
describe('LoadAccount Controller', () => { | ||
beforeAll(() => { | ||
MockDate.set(new Date()); | ||
}); | ||
|
||
afterAll(() => { | ||
MockDate.reset(); | ||
}); | ||
|
||
test('Should call LoadAccount with correct value', async () => { | ||
const { sut, loadAccountSpy } = makeSut(); | ||
const request = mockRequest(); | ||
await sut.handle(request); | ||
expect(loadAccountSpy.accountId).toBe(request.accountId); | ||
}); | ||
}); |