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', () => {});