Skip to content

Commit

Permalink
refactor(#26): added more one property to LoadAccount interface and c…
Browse files Browse the repository at this point in the history
…reate your mock
  • Loading branch information
DanielAraldi committed Jul 29, 2023
1 parent b0f8c9e commit 4cd026a
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 11 deletions.
7 changes: 6 additions & 1 deletion src/domain/usecases/load-account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,10 @@ export interface LoadAccount {
}

export namespace LoadAccount {
export type Result = { name: string; email: string; role?: string } | null;
export type Result = {
id: string;
name: string;
email: string;
role?: string;
} | null;
}
2 changes: 1 addition & 1 deletion tests/data/usecases/db-refresh-token.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { DbRefreshToken } from '@/data/usecases';
import { mockRefreshTokenParams, throwError } from '@/tests/domain/mocks';
import { throwError } from '@/tests/domain/mocks';
import {
EncrypterSpy,
LoadAccountByTokenRepositorySpy,
Expand Down
19 changes: 13 additions & 6 deletions tests/domain/mocks/mock-account.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import { AddAccount, Authentication, EditAccount } from '@/domain/usecases';
import { RefreshTokenController } from '@/presentation/controllers';
import {
AddAccount,
Authentication,
EditAccount,
LoadAccount,
} from '@/domain/usecases';
import { faker } from '@faker-js/faker';

export const mockAddAccountParams = (): AddAccount.Params => ({
Expand All @@ -13,12 +17,15 @@ export const mockAuthenticationParams = (): Authentication.Params => ({
password: faker.internet.password(),
});

export const mockRefreshTokenParams = (): RefreshTokenController.Request => ({
accessToken: faker.datatype.uuid(),
});

export const mockEditAccountParams = (): EditAccount.Params => ({
name: faker.name.fullName(),
email: faker.internet.email(),
accountId: faker.datatype.uuid(),
});

export const mockLoadAccountModel = (): LoadAccount.Result => ({
id: faker.datatype.uuid(),
name: faker.name.fullName(),
email: faker.internet.email(),
role: faker.random.word(),
});
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { RefreshTokenController } from '@/presentation/controllers';
import { mockRefreshTokenParams, throwError } from '@/tests/domain/mocks';
import { throwError } from '@/tests/domain/mocks';
import { RefreshTokenSpy, ValidationSpy } from '@/tests/presentation/mocks';
import { MissingParamError } from '@/presentation/errors';
import {
Expand All @@ -16,8 +16,9 @@ type SutTypes = {
sut: RefreshTokenController;
};

const mockRequest = (): RefreshTokenController.Request =>
mockRefreshTokenParams();
const mockRequest = (): RefreshTokenController.Request => ({
accessToken: faker.datatype.uuid(),
});

const makeSut = (): SutTypes => {
const validationSpy = new ValidationSpy();
Expand Down

0 comments on commit 4cd026a

Please sign in to comment.