directory managing

This commit is contained in:
Grégoire Chevalier 2023-05-24 09:57:23 +02:00
parent f5ce6ca005
commit 76aecfd1f0
13 changed files with 68 additions and 29 deletions

View File

@ -1,5 +1,4 @@
import { Frequency } from '../../types/frequency.enum';
export const mappingKeyToFrequency = (index: number): string => {
console.log(Frequency[index - 1]);
return Frequency[index - 1];
};

View File

@ -5,7 +5,7 @@ import { Ad } from '../domain/entities/ad';
import { AdPresenter } from '../adapters/primaries/ad.presenter';
import { CreateAdRequest } from '../domain/dtos/create-ad.request';
import { AdCreation } from '../domain/dtos/ad.creation';
import { ReccurentNormaliser } from '../domain/entities/ReccurentNormaliser';
import { ReccurentNormaliser } from '../domain/entities/reccurent-normaliser';
@Injectable()
export class AdProfile extends AutomapperProfile {

View File

@ -0,0 +1,40 @@
import { ConfigService } from '@nestjs/config';
import { Test, TestingModule } from '@nestjs/testing';
import { DefaultParamsProvider } from '../../../../adapters/secondaries/default-params.provider';
import { DefaultParams } from '../../../../domain/types/default-params.type';
const mockConfigService = {
get: jest.fn().mockImplementation(() => 'some_default_value'),
};
describe('DefaultParamsProvider', () => {
let defaultParamsProvider: DefaultParamsProvider;
beforeAll(async () => {
const module: TestingModule = await Test.createTestingModule({
imports: [],
providers: [
DefaultParamsProvider,
{
provide: ConfigService,
useValue: mockConfigService,
},
],
}).compile();
defaultParamsProvider = module.get<DefaultParamsProvider>(
DefaultParamsProvider,
);
});
it('should be defined', () => {
expect(defaultParamsProvider).toBeDefined();
});
it('should provide default params', async () => {
const params: DefaultParams = defaultParamsProvider.getParams();
expect(params.SUN_MARGIN).toBe('some_default_value');
expect(params.PASSENGER).toBe(false);
expect(params.DRIVER).toBe(false);
});
});

View File

@ -1,7 +1,7 @@
import { AmqpConnection } from '@golevelup/nestjs-rabbitmq';
import { ConfigService } from '@nestjs/config';
import { Test, TestingModule } from '@nestjs/testing';
import { Messager } from '../../adapters/secondaries/messager';
import { Messager } from '../../../../adapters/secondaries/messager';
const mockAmqpConnection = {
publish: jest.fn().mockImplementation(),

View File

@ -1,17 +1,17 @@
import { Test, TestingModule } from '@nestjs/testing';
import { CreateAdUseCase } from '../../domain/usecases/create-ad.usecase';
import { CreateAdRequest } from '../../domain/dtos/create-ad.request';
import { Messager } from '../../adapters/secondaries/messager';
import { AdsRepository } from '../../adapters/secondaries/ads.repository';
import { CreateAdCommand } from '../../commands/create-ad.command';
import { CreateAdUseCase } from '../../../domain/usecases/create-ad.usecase';
import { CreateAdRequest } from '../../../domain/dtos/create-ad.request';
import { Messager } from '../../../adapters/secondaries/messager';
import { AdsRepository } from '../../../adapters/secondaries/ads.repository';
import { CreateAdCommand } from '../../../commands/create-ad.command';
import { AutomapperModule } from '@automapper/nestjs';
import { classes } from '@automapper/classes';
import { Frequency } from '../../domain/types/frequency.enum';
import { Ad } from '../../domain/entities/ad';
import { AdProfile } from '../../mappers/ad.profile';
import { AddressRequestDTO } from '../../domain/dtos/create.address.request';
import { AdCreation } from '../../domain/dtos/ad.creation';
import { AddressCreation } from '../../domain/dtos/address.creation';
import { Frequency } from '../../../domain/types/frequency.enum';
import { Ad } from '../../../domain/entities/ad';
import { AdProfile } from '../../../mappers/ad.profile';
import { AddressRequestDTO } from '../../../domain/dtos/create.address.request';
import { AdCreation } from '../../../domain/dtos/ad.creation';
import { AddressCreation } from '../../../domain/dtos/address.creation';
const mockAddress1: AddressRequestDTO = {
position: 0,

View File

@ -1,10 +1,10 @@
import { NotFoundException } from '@nestjs/common';
import { Test, TestingModule } from '@nestjs/testing';
import { Messager } from '../../adapters/secondaries/messager';
import { FindAdByUuidQuery } from '../../queries/find-ad-by-uuid.query';
import { AdsRepository } from '../../adapters/secondaries/ads.repository';
import { FindAdByUuidUseCase } from '../../domain/usecases/find-ad-by-uuid.usecase';
import { FindAdByUuidRequest } from '../../domain/dtos/find-ad-by-uuid.request';
import { Messager } from '../../../adapters/secondaries/messager';
import { FindAdByUuidQuery } from '../../../queries/find-ad-by-uuid.query';
import { AdsRepository } from '../../../adapters/secondaries/ads.repository';
import { FindAdByUuidUseCase } from '../../../domain/usecases/find-ad-by-uuid.usecase';
import { FindAdByUuidRequest } from '../../../domain/dtos/find-ad-by-uuid.request';
const mockAd = {
uuid: 'bb281075-1b98-4456-89d6-c643d3044a91',

View File

@ -1,5 +1,5 @@
import { mappingKeyToFrequency } from '../../domain/dtos/utils/frequency.mapping';
import { Frequency } from '../../domain/types/frequency.enum';
import { mappingKeyToFrequency } from '../../../domain/dtos/utils/frequency.mapping';
import { Frequency } from '../../../domain/types/frequency.enum';
describe('frequency mapping function ', () => {
it('should return punctual', () => {

View File

@ -1,4 +1,4 @@
import { hasProperDriverSeats } from '../../domain/dtos/utils/has-driver-seats.validator';
import { hasProperDriverSeats } from '../../../domain/dtos/utils/has-driver-seats.validator';
describe('driver and/or driver seats validator', () => {
it('should validate if driver and drivers seats is not provided ', () => {

View File

@ -1,4 +1,4 @@
import { hasProperPassengerSeats } from '../../domain/dtos/utils/has-passenger-seats.validator';
import { hasProperPassengerSeats } from '../../../domain/dtos/utils/has-passenger-seats.validator';
describe('driver and/or passenger seats validator', () => {
it('should validate if passenger and passengers seats is not provided ', () => {

View File

@ -1,5 +1,5 @@
import { AddressRequestDTO } from '../../domain/dtos/create.address.request';
import { hasProperPositionIndexes } from '../../domain/dtos/utils/address-position.validator';
import { AddressRequestDTO } from '../../../domain/dtos/create.address.request';
import { hasProperPositionIndexes } from '../../../domain/dtos/utils/address-position.validator';
describe('addresses position validators', () => {
const mockAddress1: AddressRequestDTO = {
lon: 48.68944505415954,

View File

@ -1,7 +1,7 @@
import { CreateAdRequest } from '../../domain/dtos/create-ad.request';
import { ScheduleDTO } from '../../domain/dtos/create.schedule.dto';
import { ReccurentNormaliser } from '../../domain/entities/ReccurentNormaliser';
import { Frequency } from '../../domain/types/frequency.enum';
import { CreateAdRequest } from '../../../domain/dtos/create-ad.request';
import { ScheduleDTO } from '../../../domain/dtos/create.schedule.dto';
import { ReccurentNormaliser } from '../../../domain/entities/reccurent-normaliser';
import { Frequency } from '../../../domain/types/frequency.enum';
describe('reccurent normalizer transformer for punctual ad ', () => {
const reccurentNormaliser = new ReccurentNormaliser();
it('should transform punctual ad into reccurent ad ', () => {