Skip to content

Commit

Permalink
add some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
WojciechGrancow committed Oct 20, 2023
1 parent ca59c48 commit 5838b81
Show file tree
Hide file tree
Showing 11 changed files with 41 additions and 6 deletions.
1 change: 0 additions & 1 deletion apps/server/src/modules/deletion/entities/index.ts

This file was deleted.

2 changes: 2 additions & 0 deletions apps/server/src/modules/deletion/entity/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './deletion-request.entity';
export * from './deletion-log.entity';
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { setupEntities } from '@shared/testing';
import { DeletionRequestEntity } from '../deletion-request.entity';
import { deletionRequestEntityFactory } from './factory/deletion-request.entity.factory';

describe(DeletionRequestEntity.name, () => {
beforeAll(async () => {
await setupEntities();
});

describe('constructor', () => {
describe('When constructor is called', () => {
it('should create a deletionRequest by passing required properties', () => {
const entity: DeletionRequestEntity = deletionRequestEntityFactory.build();

expect(entity instanceof DeletionRequestEntity).toEqual(true);
});
});
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { ObjectId } from '@mikro-orm/mongodb';
import { BaseFactory } from '@shared/testing';
import { DeletionRequestEntity, DeletionRequestEntityProps } from '../..';

export const deletionRequestEntityFactory = BaseFactory.define<DeletionRequestEntity, DeletionRequestEntityProps>(
DeletionRequestEntity,
() => {
return {
source: 'shd',
deleteAfter: new Date(),
userId: new ObjectId(),
};
}
);
2 changes: 1 addition & 1 deletion apps/server/src/modules/deletion/repo/deletion-log.repo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { EntityManager } from '@mikro-orm/mongodb';
import { Injectable } from '@nestjs/common';
import { EntityId } from '@shared/domain';
import { DeletionLog } from '../domain/deletion-log.do';
import { DeletionLogEntity } from '../entities/deletion-log.entity';
import { DeletionLogEntity } from '../entity/deletion-log.entity';
import { DeletionLogMapper } from './mapper/deletion-log.mapper';

@Injectable()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { EntityManager } from '@mikro-orm/mongodb';
import { Injectable } from '@nestjs/common';
import { EntityId } from '@shared/domain';
import { DeletionRequest } from '../domain/deletion-request.do';
import { DeletionRequestEntity } from '../entities';
import { DeletionRequestEntity } from '../entity';
import { DeletionRequestMapper } from './mapper/deletion-request.mapper';

@Injectable()
Expand Down
3 changes: 2 additions & 1 deletion apps/server/src/modules/deletion/repo/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from './classes.repo';
export * from './deletion-log.repo';
export * from './deletion-request.repo';
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ObjectId } from '@mikro-orm/mongodb';
import { DeletionLogEntity } from '../../entities/deletion-log.entity';
import { DeletionLogEntity } from '../../entity/deletion-log.entity';
import { DeletionLog } from '../../domain/deletion-log.do';

export class DeletionLogMapper {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ObjectId } from '@mikro-orm/mongodb';
import { DeletionRequest } from '../../domain/deletion-request.do';
import { DeletionRequestEntity } from '../../entities';
import { DeletionRequestEntity } from '../../entity';

export class DeletionRequestMapper {
static mapToDO(entity: DeletionRequestEntity): DeletionRequest {
Expand Down

0 comments on commit 5838b81

Please sign in to comment.