From c973e870b5b007e431b599a0dbb347157b62bebf Mon Sep 17 00:00:00 2001 From: "italo.amaral" Date: Thu, 19 Oct 2023 09:24:05 -0300 Subject: [PATCH 1/2] fix(CC-69): pre release linting problems --- .../create-single-appointment.service.ts | 10 +++------- .../create-psychologist.spec.ts | 16 ++++++++++------ .../delete-psychologist.spec.ts | 15 ++++++++++----- .../update-psychologist.spec.ts | 15 +++++++++------ 4 files changed, 32 insertions(+), 24 deletions(-) diff --git a/libs/core-rest-api/core/src/domains/appointment/use-cases/create-single-appointment/create-single-appointment.service.ts b/libs/core-rest-api/core/src/domains/appointment/use-cases/create-single-appointment/create-single-appointment.service.ts index 5dcd74e..7cf2998 100644 --- a/libs/core-rest-api/core/src/domains/appointment/use-cases/create-single-appointment/create-single-appointment.service.ts +++ b/libs/core-rest-api/core/src/domains/appointment/use-cases/create-single-appointment/create-single-appointment.service.ts @@ -1,17 +1,15 @@ /* eslint-disable @nx/enforce-module-boundaries */ -import { applicationValidateOrReject } from '@clinicControl/core-rest-api/core/src/shared/validators/validate-or-reject'; import { ConflictException } from '@nestjs/common'; import { plainToInstance } from 'class-transformer'; import { APPOINTMENT_ERROR_MESSAGES } from '../../../../shared/errors/error-messages'; +import { applicationValidateOrReject } from '../../../../shared/validators/validate-or-reject'; import { AppointmentEntity } from '../../entities/appointment/entity'; import { ICreateAppointmentServiceProps } from '../../interfaces/appointment'; import { AppointmentDatabaseRepository } from '../../repositories/database-repository'; import { CreateSingleAppointmentDto } from './create-single-appointment-dto'; export class CreateSingleAppointmentService { - constructor( - private appointmentDatabaseRepository: AppointmentDatabaseRepository - ) {} + constructor(private appointmentDatabaseRepository: AppointmentDatabaseRepository) {} async execute( createSingleAppointmentDto: ICreateAppointmentServiceProps @@ -30,9 +28,7 @@ export class CreateSingleAppointmentService { ); if (isAppointmentExist) { - throw new ConflictException( - APPOINTMENT_ERROR_MESSAGES['CONFLICTING_DATE_TIME'] - ); + throw new ConflictException(APPOINTMENT_ERROR_MESSAGES['CONFLICTING_DATE_TIME']); } // Create diff --git a/libs/core-rest-api/core/src/domains/psychologist/use-cases/create-psychologist/create-psychologist.spec.ts b/libs/core-rest-api/core/src/domains/psychologist/use-cases/create-psychologist/create-psychologist.spec.ts index 2035671..c28a96b 100644 --- a/libs/core-rest-api/core/src/domains/psychologist/use-cases/create-psychologist/create-psychologist.spec.ts +++ b/libs/core-rest-api/core/src/domains/psychologist/use-cases/create-psychologist/create-psychologist.spec.ts @@ -1,14 +1,20 @@ -import { makePsychologist } from '@clinicControl/root/libs/core-rest-api/adapters/tests/factories/make-psychologist'; - +import { fakerPT_BR as faker } from '@faker-js/faker'; import { ConflictException } from '@nestjs/common'; import { PSYCHOLOGIST_ERROR_MESSAGES } from '../../../../shared/errors/error-messages'; +import { Plan, Role } from '../../../../shared/interfaces/payments'; import { InMemoryPsychologistDatabaseRepository } from '../../repositories/database-in-memory-repository'; import { PsychologistDatabaseRepository } from '../../repositories/database-repository'; import { CreatePsychologistService } from './create-psychologist.service'; describe('[psychologist] Create Psychologist Service', () => { - const fakePsychologist = makePsychologist(); + const fakePsychologist = { + name: faker.person.fullName(), + email: faker.internet.email(), + password: faker.internet.password({ length: 8 }), + role: Role.PSYCHOLOGIST, + plan: Plan.PREMIUM, + }; let service: CreatePsychologistService; let databaseRepository: PsychologistDatabaseRepository; @@ -33,9 +39,7 @@ describe('[psychologist] Create Psychologist Service', () => { await service.execute(fakePsychologist); await expect(service.execute(fakePsychologist)).rejects.toThrow( - new ConflictException( - PSYCHOLOGIST_ERROR_MESSAGES['PSYCHOLOGIST_ALREADY_EXISTS'] - ) + new ConflictException(PSYCHOLOGIST_ERROR_MESSAGES['PSYCHOLOGIST_ALREADY_EXISTS']) ); }); }); diff --git a/libs/core-rest-api/core/src/domains/psychologist/use-cases/delete-psychologist/delete-psychologist.spec.ts b/libs/core-rest-api/core/src/domains/psychologist/use-cases/delete-psychologist/delete-psychologist.spec.ts index bb943b8..883655e 100644 --- a/libs/core-rest-api/core/src/domains/psychologist/use-cases/delete-psychologist/delete-psychologist.spec.ts +++ b/libs/core-rest-api/core/src/domains/psychologist/use-cases/delete-psychologist/delete-psychologist.spec.ts @@ -1,12 +1,19 @@ -import { makePsychologist } from '@clinicControl/root/libs/core-rest-api/adapters/tests/factories/make-psychologist'; +import { fakerPT_BR as faker } from '@faker-js/faker'; import { ConflictException } from '@nestjs/common'; import { PSYCHOLOGIST_ERROR_MESSAGES } from '../../../../shared/errors/error-messages'; +import { Plan, Role } from '../../../../shared/interfaces/payments'; import { InMemoryPsychologistDatabaseRepository } from '../../repositories/database-in-memory-repository'; import { PsychologistDatabaseRepository } from '../../repositories/database-repository'; import { DeletePsychologistService } from './delete-psychologist.service'; describe('[psychologist] Delete Psychologist Service', () => { - const fakePsychologist = makePsychologist(); + const fakePsychologist = { + name: faker.person.fullName(), + email: faker.internet.email(), + password: faker.internet.password({ length: 8 }), + role: Role.PSYCHOLOGIST, + plan: Plan.PREMIUM, + }; let service: DeletePsychologistService; let databaseRepository: PsychologistDatabaseRepository; @@ -28,9 +35,7 @@ describe('[psychologist] Delete Psychologist Service', () => { it('should throw error if psychologist does not exist', async () => { await expect(service.execute(fakePsychologist.email)).rejects.toThrow( - new ConflictException( - PSYCHOLOGIST_ERROR_MESSAGES['PSYCHOLOGIST_NOT_FOUND'] - ) + new ConflictException(PSYCHOLOGIST_ERROR_MESSAGES['PSYCHOLOGIST_NOT_FOUND']) ); }); }); diff --git a/libs/core-rest-api/core/src/domains/psychologist/use-cases/update-psychologist/update-psychologist.spec.ts b/libs/core-rest-api/core/src/domains/psychologist/use-cases/update-psychologist/update-psychologist.spec.ts index c7b20b3..f32136e 100644 --- a/libs/core-rest-api/core/src/domains/psychologist/use-cases/update-psychologist/update-psychologist.spec.ts +++ b/libs/core-rest-api/core/src/domains/psychologist/use-cases/update-psychologist/update-psychologist.spec.ts @@ -1,14 +1,19 @@ -import { makePsychologist } from '@clinicControl/root/libs/core-rest-api/adapters/tests/factories/make-psychologist'; import { fakerPT_BR as faker } from '@faker-js/faker'; import { ConflictException } from '@nestjs/common'; import { PSYCHOLOGIST_ERROR_MESSAGES } from '../../../../shared/errors/error-messages'; -import { Plan } from '../../../../shared/interfaces/payments'; +import { Plan, Role } from '../../../../shared/interfaces/payments'; import { InMemoryPsychologistDatabaseRepository } from '../../repositories/database-in-memory-repository'; import { PsychologistDatabaseRepository } from '../../repositories/database-repository'; import { UpdatePsychologistService } from './update-psychologist.service'; describe('[psychologist] Update Psychologist Service', () => { - const fakePsychologist = makePsychologist(); + const fakePsychologist = { + name: faker.person.fullName(), + email: faker.internet.email(), + password: faker.internet.password({ length: 8 }), + role: Role.PSYCHOLOGIST, + plan: Plan.PREMIUM, + }; let service: UpdatePsychologistService; let databaseRepository: PsychologistDatabaseRepository; @@ -65,9 +70,7 @@ describe('[psychologist] Update Psychologist Service', () => { }; await expect(service.execute(newPsychologistInfos)).rejects.toThrow( - new ConflictException( - PSYCHOLOGIST_ERROR_MESSAGES['PSYCHOLOGIST_NOT_FOUND'] - ) + new ConflictException(PSYCHOLOGIST_ERROR_MESSAGES['PSYCHOLOGIST_NOT_FOUND']) ); }); }); From f11fa57227ac74a1dcafcc29944f10801d42a246 Mon Sep 17 00:00:00 2001 From: "italo.amaral" Date: Thu, 19 Oct 2023 09:29:27 -0300 Subject: [PATCH 2/2] test(CC-69): fixed update psychologist test --- .../use-cases/update-psychologist/update-psychologist.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/core-rest-api/core/src/domains/psychologist/use-cases/update-psychologist/update-psychologist.spec.ts b/libs/core-rest-api/core/src/domains/psychologist/use-cases/update-psychologist/update-psychologist.spec.ts index f32136e..50182c1 100644 --- a/libs/core-rest-api/core/src/domains/psychologist/use-cases/update-psychologist/update-psychologist.spec.ts +++ b/libs/core-rest-api/core/src/domains/psychologist/use-cases/update-psychologist/update-psychologist.spec.ts @@ -12,7 +12,7 @@ describe('[psychologist] Update Psychologist Service', () => { email: faker.internet.email(), password: faker.internet.password({ length: 8 }), role: Role.PSYCHOLOGIST, - plan: Plan.PREMIUM, + plan: Plan.BASIC, }; let service: UpdatePsychologistService;