/
system.spec.ts
34 lines (24 loc) · 1.21 KB
/
system.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import { Test, TestingModule } from '@nestjs/testing';
import { EnviromentVariableDirectusIPNotDefinedException } from '@system/directus/directus.exception';
import { createTestingModuleOnInnerFunction, setSpecSystemEnviromentVariables } from '@utils/spec.utils';
import { CatController } from '../features/cat/cat.controller';
import { CatModule } from '../features/cat/cat.module';
import { SystemModule } from './system.module';
describe('[System] Unit Tests Spec', () => {
let module: TestingModule;
async function setModules(modules: Array<any>) {
module = await Test.createTestingModule({
imports: modules,
}).compile();
}
it('Expected to throw EnviromentVariableDirectusIPNotDefined exception', async () => {
await setSpecSystemEnviromentVariables(false);
await setModules([CatModule]);
const catController = module.get<CatController>(CatController);
expect(catController.findAll('accessToken')).rejects.toThrowError(EnviromentVariableDirectusIPNotDefinedException);
});
it('Expect to create system module without errors', async () => {
await setSpecSystemEnviromentVariables(true);
expect(createTestingModuleOnInnerFunction([SystemModule])()).toBeDefined();
});
});