Skip to content

Commit ed62aa3

Browse files
committed
MAT-9484: fix test that became async
1 parent 9ff34d3 commit ed62aa3

1 file changed

Lines changed: 15 additions & 5 deletions

File tree

src/global.module.spec.ts

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,24 @@
1+
import 'reflect-metadata';
12
import { GlobalModule } from './global.module';
23
import { ConfigModule } from '@nestjs/config';
34
import { Logger } from '@nestjs/common';
45
import { AppConfigService } from './config/config.service';
56

67
describe('GlobalModule', () => {
7-
it('should have the specified imports', () => {
8-
const imports = Reflect.getMetadata('imports', GlobalModule);
9-
expect(imports).toBeArrayOfSize(1);
10-
expect(imports[0].global).toBeTrue();
11-
expect(imports[0].module).toBe(ConfigModule);
8+
it('should have the specified imports', async () => {
9+
const imports = Reflect.getMetadata('imports', GlobalModule) as unknown[]; //promise?
10+
expect(Array.isArray(imports)).toBe(true);
11+
expect(imports).toHaveLength(1);
12+
13+
// imports[0] is a promise now?
14+
const first = imports[0] as any;
15+
const resolved = typeof first?.then === 'function' ? await first : first;
16+
expect(resolved).toEqual(
17+
expect.objectContaining({
18+
module: ConfigModule,
19+
global: true,
20+
}),
21+
);
1222
});
1323

1424
it('should have the specified controllers', () => {

0 commit comments

Comments
 (0)