-
Notifications
You must be signed in to change notification settings - Fork 2
/
raw.e2e-spec.ts
56 lines (51 loc) 路 1.61 KB
/
raw.e2e-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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import { Module } from '@nestjs/common';
import { NestFactory } from '@nestjs/core';
import { ConfigModule } from '../src';
import { TestModule } from './fixtures/test.module';
import { FirstConfig } from './fixtures/first.config';
import { SecondConfig } from './fixtures/second.config';
import { RAW_CONFIG } from '../src/tokens';
describe('Raw', () => {
it('override', async () => {
@Module({
imports: [
ConfigModule.forRoot({
providers: [
{
provide: RAW_CONFIG,
useValue: {
FIRST__STRING_VAR: 'stringVar',
FIRST__STRING_VAR_WITH_DEFAULT: 'stringVarWithDefault',
FIRST__INT_VAR: '1',
FIRST__INT_VAR_WITH_DEFAULT: '7',
FIRST__NUMBER_VAR: '1.1',
FIRST__NUMBER_VAR_WITH_DEFAULT: '7.7',
FIRST__BOOL_VAR: 'true',
FIRST__BOOL_VAR_WITH_DEFAULT: 'true',
},
},
],
}),
TestModule,
],
})
class AppModule {}
const app = await NestFactory.createApplicationContext(AppModule);
const firstConfig = app.get<FirstConfig>(FirstConfig);
const secondConfig = app.get<SecondConfig>(SecondConfig);
expect(firstConfig).toMatchObject({
stringVar: 'stringVar',
stringVarWithDefault: 'stringVarWithDefault',
intVar: 1,
intVarWithDefault: 7,
numberVar: 1.1,
numberVarWithDefault: 7.7,
boolVar: true,
boolVarWithDefault: true,
});
expect(secondConfig).toMatchObject({
variable: 'value',
});
await app.close();
});
});