Unit tests

This commit is contained in:
Bastian Wagner
2026-02-27 11:03:35 +01:00
parent 5aa97cd8ea
commit f86c9c681a
15 changed files with 166 additions and 45 deletions

2
api/mocks/index.ts Normal file
View File

@@ -0,0 +1,2 @@
export * from './repositories';
export * from './services';

View File

@@ -0,0 +1,2 @@
export * from './system.repository.mock';
export * from './user.repository.mock';

View File

@@ -0,0 +1,41 @@
import { KeySystem } from "src/model/entitites/system.entity";
import { CreateSystemDto } from "src/modules/system/dto/create-system.dto";
export class MockKeySystemRepository {
create = jest.fn().mockImplementation((register: CreateSystemDto) => {
const x = new KeySystem();
x.name = register.name;
return x;
});
save = jest.fn().mockImplementation((system: KeySystem) => {
system.id = '1234';
system.createdAt = new Date();
return Promise.resolve(system);
});
softRemove = jest.fn().mockImplementation((system: KeySystem) => {
system.deletedAt = new Date();
return Promise.resolve(system);
});
findOne = jest.fn().mockImplementation(() => {
const system = this.createKeySystem();
return system;
})
findOneOrFail = jest.fn().mockImplementation(() => {
const system = this.createKeySystem();
return system;
})
private createKeySystem(): KeySystem {
const s = new KeySystem();
s.id = '1234';
s.name = 'Testname1234';
s.createdAt = new Date();
return s;
}
}

View File

@@ -0,0 +1 @@
export * from './mail.service.mock';

View File

@@ -0,0 +1,3 @@
export class MockMailService {
}