Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

69 core definir schema do prisma #77

Merged
merged 2 commits into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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'])
);
});
});
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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'])
);
});
});
Original file line number Diff line number Diff line change
@@ -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.BASIC,
};

let service: UpdatePsychologistService;
let databaseRepository: PsychologistDatabaseRepository;
Expand Down Expand Up @@ -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'])
);
});
});