File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import 'reflect-metadata' ;
12import { GlobalModule } from './global.module' ;
23import { ConfigModule } from '@nestjs/config' ;
34import { Logger } from '@nestjs/common' ;
45import { AppConfigService } from './config/config.service' ;
56
67describe ( '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' , ( ) => {
You can’t perform that action at this time.
0 commit comments