AFFiNE/apps/server/tests/config.spec.ts

36 lines
813 B
TypeScript
Raw Normal View History

import { Test, TestingModule } from '@nestjs/testing';
2023-09-01 22:41:29 +03:00
import test from 'ava';
import { Config, ConfigModule } from '../src/config';
let config: Config;
let module: TestingModule;
2023-09-01 22:41:29 +03:00
test.beforeEach(async () => {
module = await Test.createTestingModule({
imports: [ConfigModule.forRoot()],
}).compile();
config = module.get(Config);
});
test.afterEach.always(async () => {
await module.close();
});
2023-09-01 22:41:29 +03:00
test('should be able to get config', t => {
t.true(typeof config.host === 'string');
t.is(config.env, 'test');
});
2023-09-01 22:41:29 +03:00
test('should be able to override config', async t => {
const module = await Test.createTestingModule({
imports: [
ConfigModule.forRoot({
host: 'testing',
}),
],
}).compile();
const config = module.get(Config);
t.is(config.host, 'testing');
});