Skip to content

Commit 516e085

Browse files
author
ashleigh
committed
Prettier
1 parent 3d164e6 commit 516e085

File tree

2 files changed

+41
-23
lines changed

2 files changed

+41
-23
lines changed

src/__tests__/config.module.spec.ts

Lines changed: 35 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ describe('Config Nest Module', () => {
5555

5656
@Configurable()
5757
testConfig(server: { port: number }) {
58-
return {serverPort: server.port};
58+
return { serverPort: server.port };
5959
}
6060
}
6161

@@ -66,16 +66,18 @@ describe('Config Nest Module', () => {
6666
providers: [ComponentTest],
6767
}).compile();
6868
const componentTest = module.get<ComponentTest>(ComponentTest);
69-
expect(componentTest.testConfig({port: 42})).toEqual({serverPort: 42});
69+
expect(componentTest.testConfig({ port: 42 })).toEqual({ serverPort: 42 });
7070
});
7171
it('ConfigParam decorator on null argument', async () => {
7272
@Injectable()
7373
class ComponentTest {
7474
constructor() {}
7575

7676
@Configurable()
77-
testConfig(@ConfigParam('config.server') server: null | { port: number },) {
78-
return {serverPort: server.port };
77+
testConfig(
78+
@ConfigParam('config.server') server: null | { port: number },
79+
) {
80+
return { serverPort: server.port };
7981
}
8082
}
8183

@@ -86,7 +88,7 @@ describe('Config Nest Module', () => {
8688
providers: [ComponentTest],
8789
}).compile();
8890
const componentTest = module.get<ComponentTest>(ComponentTest);
89-
expect(componentTest.testConfig(null)).toEqual({serverPort: 2000});
91+
expect(componentTest.testConfig(null)).toEqual({ serverPort: 2000 });
9092
});
9193
it('Multiple ConfigParam decorators', async () => {
9294
@Injectable()
@@ -96,7 +98,7 @@ describe('Config Nest Module', () => {
9698
@Configurable()
9799
testConfig(
98100
@ConfigParam('config.server') server?: { port: number },
99-
@ConfigParam('config.stub') stub?: { port: number }
101+
@ConfigParam('config.stub') stub?: { port: number },
100102
) {
101103
return { serverPort: server.port, stubPort: stub.port };
102104
}
@@ -109,13 +111,16 @@ describe('Config Nest Module', () => {
109111
providers: [ComponentTest],
110112
}).compile();
111113
const componentTest = module.get<ComponentTest>(ComponentTest);
112-
expect(componentTest.testConfig()).toEqual({ serverPort: 2000, stubPort: 2000 });
114+
expect(componentTest.testConfig()).toEqual({
115+
serverPort: 2000,
116+
stubPort: 2000,
117+
});
113118
});
114119
it('ConfigParam decorators in a static factory method with injected service', async () => {
115120
class ComponentTest {
116121
constructor(
117122
private readonly serverPort: number,
118-
private readonly stubPort: number
123+
private readonly stubPort: number,
119124
) {}
120125

121126
testConfig() {
@@ -127,7 +132,7 @@ describe('Config Nest Module', () => {
127132
@Configurable()
128133
static async get(
129134
@ConfigParam('config.server') server: any,
130-
@ConfigParam('config.stub') stub: any
135+
@ConfigParam('config.stub') stub: any,
131136
) {
132137
return new ComponentTest(server.port, stub.port);
133138
}
@@ -137,34 +142,39 @@ describe('Config Nest Module', () => {
137142
imports: [
138143
ConfigModule.load(path.resolve(__dirname, '__stubs__', '**/*.ts')),
139144
],
140-
providers: [{
141-
provide: 'ComponentTest',
142-
useFactory: ComponentTestFactory.get,
143-
inject: [ConfigService]
144-
}],
145+
providers: [
146+
{
147+
provide: 'ComponentTest',
148+
useFactory: ComponentTestFactory.get,
149+
inject: [ConfigService],
150+
},
151+
],
145152
}).compile();
146153

147154
const componentTest = module.get<ComponentTest>('ComponentTest');
148-
expect(componentTest.testConfig()).toEqual({serverPort: 2000, stubPort: 2000});
155+
expect(componentTest.testConfig()).toEqual({
156+
serverPort: 2000,
157+
stubPort: 2000,
158+
});
149159
});
150160

151161
it('ConfigParam decorators in a static factory method with injected class', async () => {
152162
class ComponentTest {
153163
constructor(
154164
private readonly serverPort: number,
155-
private readonly stubPort: number
165+
private readonly stubPort: number,
156166
) {}
157167

158168
testConfig() {
159-
return {serverPort: this.serverPort, stubPort: this.stubPort};
169+
return { serverPort: this.serverPort, stubPort: this.stubPort };
160170
}
161171
}
162172

163173
class ComponentTestFactory {
164174
@Configurable()
165175
static async get(
166176
@ConfigParam('config.server') server: any,
167-
@ConfigParam('config.stub') stub: any
177+
@ConfigParam('config.stub') stub: any,
168178
) {
169179
return new ComponentTest(server.port, stub.port);
170180
}
@@ -177,18 +187,21 @@ describe('Config Nest Module', () => {
177187
providers: [
178188
{
179189
provide: 'CONFIG_SERVICE_CLASS',
180-
useValue: ConfigService
190+
useValue: ConfigService,
181191
},
182192
{
183193
provide: 'ComponentTest',
184194
useFactory: ComponentTestFactory.get,
185-
inject: ['CONFIG_SERVICE_CLASS']
186-
}
195+
inject: ['CONFIG_SERVICE_CLASS'],
196+
},
187197
],
188198
}).compile();
189199

190200
const componentTest = module.get<ComponentTest>('ComponentTest');
191-
expect(componentTest.testConfig()).toEqual({serverPort: 2000, stubPort: 2000});
201+
expect(componentTest.testConfig()).toEqual({
202+
serverPort: 2000,
203+
stubPort: 2000,
204+
});
192205
});
193206

194207
it('ConfigParam decorator default value', async () => {

src/decorators/ConfigParam.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,12 @@ export const ConfigParam = (
1111
// Add this parameter
1212
existingParameters.push({ parameterIndex, propertyKey, configKey, fallback });
1313
// Update the required parameters for this method
14-
Reflect.defineMetadata(CONFIG_PARAMS, existingParameters, target, propertyKey);
14+
Reflect.defineMetadata(
15+
CONFIG_PARAMS,
16+
existingParameters,
17+
target,
18+
propertyKey,
19+
);
1520
return target;
1621
};
1722
export default ConfigParam;

0 commit comments

Comments
 (0)