Skip to content

Commit

Permalink
test(#26): ensure LoadAccountController call LoadAccount with correct…
Browse files Browse the repository at this point in the history
… value
  • Loading branch information
DanielAraldi committed Jul 29, 2023
1 parent 9f329da commit ded75e8
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions tests/presentation/controllers/load-account-controller.spec.ts
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);
});
});

0 comments on commit ded75e8

Please sign in to comment.