/
applicationManager.test.ts
36 lines (28 loc) 路 1.08 KB
/
applicationManager.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import { MidwayApplicationManager, BaseFramework } from '../../src';
import { MidwayFrameworkType } from '@midwayjs/decorator';
describe('test/common/applicationManager.test.ts', () => {
it('should test application manager', async () => {
const manager = new MidwayApplicationManager();
class CustomFramework1 extends BaseFramework<any, any, any> {
applicationInitialize(options): any {
this.app = {};
}
configure(options: any): any {
return {};
}
getFrameworkType() {
return MidwayFrameworkType.EMPTY;
}
run(): Promise<void> {
return Promise.resolve(undefined);
}
}
const framework = new CustomFramework1({} as any);
await framework.initialize();
manager.addFramework('test', framework);
expect(manager.getApplication('test')).toBeDefined();
expect(manager.getApplication(MidwayFrameworkType.EMPTY)).toBeDefined();
expect(manager.getApplication('xxxx')).toBeUndefined();
expect(manager.getApplications([MidwayFrameworkType.EMPTY, 'test', 'xxx']).length).toEqual(2);
});
});