From 393105d525c3bf4348fdb78569cf4ac247d9f54e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Chevalier?= Date: Fri, 5 May 2023 10:49:42 +0200 Subject: [PATCH] WIP create user --- src/modules/ad/commands/create-ad.command.ts | 9 +++++++++ .../ad/domain/dtos/create-ad.request.ts | 1 + src/modules/ad/domain/entities/address.ts | 0 .../ad/tests/unit/create-ad.usecase.spec.ts | 20 +++++++++++++++++++ 4 files changed, 30 insertions(+) create mode 100644 src/modules/ad/commands/create-ad.command.ts create mode 100644 src/modules/ad/domain/dtos/create-ad.request.ts create mode 100644 src/modules/ad/domain/entities/address.ts diff --git a/src/modules/ad/commands/create-ad.command.ts b/src/modules/ad/commands/create-ad.command.ts new file mode 100644 index 0000000..b4f1e8d --- /dev/null +++ b/src/modules/ad/commands/create-ad.command.ts @@ -0,0 +1,9 @@ +import { CreateAdRequest } from '../domain/dtos/create-ad.request'; + +export class CreateAdCommand { + readonly createAdRequest: CreateAdRequest; + + constructor(request: CreateAdRequest) { + this.createAdRequest = request; + } +} diff --git a/src/modules/ad/domain/dtos/create-ad.request.ts b/src/modules/ad/domain/dtos/create-ad.request.ts new file mode 100644 index 0000000..f7cbd04 --- /dev/null +++ b/src/modules/ad/domain/dtos/create-ad.request.ts @@ -0,0 +1 @@ +export class CreateAdRequest {} diff --git a/src/modules/ad/domain/entities/address.ts b/src/modules/ad/domain/entities/address.ts new file mode 100644 index 0000000..e69de29 diff --git a/src/modules/ad/tests/unit/create-ad.usecase.spec.ts b/src/modules/ad/tests/unit/create-ad.usecase.spec.ts index fd7ee31..9d7d89b 100644 --- a/src/modules/ad/tests/unit/create-ad.usecase.spec.ts +++ b/src/modules/ad/tests/unit/create-ad.usecase.spec.ts @@ -1,6 +1,8 @@ import { classes } from '@automapper/classes'; import { AutomapperModule } from '@automapper/nestjs'; import { Ad } from '../../domain/entities/ad'; +import { Test, TestingModule } from '@nestjs/testing'; +import { CreateAdUseCase } from '../../domain/usecases/create-ad.usecase'; const mockAddress1: Address = { position: 0, lon: '48.68944505415954', @@ -41,7 +43,25 @@ const mockMessager = { describe('CreateAdUseCase', () => { it('should be defined', () => {}); + let createAdUseCase: CreateAdUseCase; + beforeAll(async () => { + const module: TestingModule = await Test.createTestingModule({ + imports: [], + providers: [ + { + provide: AdsRepository, + useValue: mockAdRepository, + }, + { + provide: Messager, + useValue: mockMessager, + }, + CreateAdUseCase, + ], + }).compile(); + createAdUseCase = module.get(CreateAdUseCase); + }); describe('execution', () => { it('should create an new ad', () => {}); it('should throw an error if the ad already exists', () => {});