(
injectionKey: InjectionToken,
scope: Scope,
additionalProviders: Array<Provider> = [],
)
| 13 | class A {} |
| 14 | |
| 15 | async function testHelper( |
| 16 | injectionKey: InjectionToken, |
| 17 | scope: Scope, |
| 18 | additionalProviders: Array<Provider> = [], |
| 19 | ): Promise<NestApplicationContext> { |
| 20 | const nestContainer = new NestContainer(); |
| 21 | const injector = new Injector(); |
| 22 | const instanceLoader = new InstanceLoader( |
| 23 | nestContainer, |
| 24 | injector, |
| 25 | new GraphInspector(nestContainer), |
| 26 | ); |
| 27 | const { moduleRef } = (await nestContainer.addModule(class T {}, []))!; |
| 28 | |
| 29 | nestContainer.addProvider( |
| 30 | { |
| 31 | provide: injectionKey, |
| 32 | useClass: A, |
| 33 | scope, |
| 34 | }, |
| 35 | moduleRef.token, |
| 36 | ); |
| 37 | |
| 38 | for (const provider of additionalProviders) { |
| 39 | nestContainer.addProvider(provider, moduleRef.token); |
| 40 | } |
| 41 | |
| 42 | nestContainer.addInjectable( |
| 43 | { |
| 44 | provide: injectionKey, |
| 45 | useClass: A, |
| 46 | scope, |
| 47 | }, |
| 48 | moduleRef.token, |
| 49 | 'interceptor', |
| 50 | ); |
| 51 | |
| 52 | const modules = nestContainer.getModules(); |
| 53 | await instanceLoader.createInstancesOfDependencies(modules); |
| 54 | |
| 55 | const applicationContext = new NestApplicationContext(nestContainer); |
| 56 | return applicationContext; |
| 57 | } |
| 58 | |
| 59 | describe('listenToShutdownSignals', () => { |
| 60 | it('shutdown process should not be interrupted by another handler', async () => { |
no test coverage detected