|
1 | 1 | import { beforeEach, expect, test } from '@jest/globals'; |
2 | | -import { App, AppErrorEvent, AppEvent, AppExecutedEvent, onAppError, onAppExecute, onAppExecuted, onAppShutdown } from '../src/app.js'; |
3 | | -import { ClassType, Inject, isClass } from '@deepkit/core'; |
| 2 | +import { App, onAppError, onAppExecute, onAppExecuted, onAppShutdown } from '../src/app.js'; |
| 3 | +import { ClassType, getCurrentDirName, Inject, isClass } from '@deepkit/core'; |
4 | 4 | import { ProviderWithScope, Token } from '@deepkit/injector'; |
5 | 5 | import { AppModule, createModule, createModuleClass } from '../src/module.js'; |
6 | | -import { BaseEvent, DataEvent, DataEventToken, EventDispatcher, eventDispatcher, EventToken } from '@deepkit/event'; |
| 6 | +import { BaseEvent, DataEvent, DataEventToken, EventDispatcher, eventDispatcher, EventOfEventToken, EventToken } from '@deepkit/event'; |
7 | 7 | import { cli, Command, Flag } from '../src/command.js'; |
8 | 8 | import { ControllerConfig, ServiceContainer } from '../src/service-container.js'; |
9 | 9 |
|
| 10 | +const dirname = getCurrentDirName(); |
| 11 | + |
10 | 12 | Error.stackTraceLimit = 100; |
11 | 13 |
|
12 | 14 | class BaseConfig { |
@@ -53,7 +55,7 @@ test('loadConfigFromEnvVariables', async () => { |
53 | 55 |
|
54 | 56 | test('loadConfigFromEnvFile', async () => { |
55 | 57 | const app = new App({ config: Config, providers: [Service], imports: [new BaseModule] }); |
56 | | - app.loadConfigFromEnv({ envFilePath: __dirname + '/test.env' }); |
| 58 | + app.loadConfigFromEnv({ envFilePath: dirname + '/test.env' }); |
57 | 59 |
|
58 | 60 | const service = app.get(Service); |
59 | 61 | expect(service.token).toBe('changed5'); |
@@ -595,10 +597,10 @@ test('events', async () => { |
595 | 597 | class MyService { |
596 | 598 | } |
597 | 599 |
|
598 | | - let executeEvent: AppEvent | undefined = undefined; |
599 | | - let executedEvent: AppExecutedEvent | undefined = undefined; |
600 | | - let errorEvent: AppErrorEvent | undefined = undefined; |
601 | | - let shutdownEvent: AppEvent | undefined = undefined; |
| 600 | + let executeEvent: EventOfEventToken<typeof onAppExecute> | undefined = undefined; |
| 601 | + let executedEvent: EventOfEventToken<typeof onAppExecuted> | undefined = undefined; |
| 602 | + let errorEvent: EventOfEventToken<typeof onAppError> | undefined = undefined; |
| 603 | + let shutdownEvent: EventOfEventToken<typeof onAppShutdown> | undefined = undefined; |
602 | 604 |
|
603 | 605 | const app = new App({ |
604 | 606 | providers: [MyService], |
|
0 commit comments