Files
cocos4/scripts/build-engine/tests/stats-query/constant-manager.test.ts
T
PP 810de3fe68 support number type of engine constant (#12012)
* add constant type for number

* support number type of build time constant

* publish 4.3.11

* update test

* support genCCEnvConstants && publish 4.3.12

* NET_MODE is public, SERVER_MODE is private

* update deps

* fix exportDynamicConstants

* update test

* publish 4.3.14

* update deps

* support JIT is not dynamic

* update lock
2022-07-21 23:33:44 +08:00

66 lines
1.7 KiB
TypeScript

import { ConstantManager } from '../../src/constant-manager';
const cm = new ConstantManager(__dirname);
test('generateInternalConstants', () => {
expect(cm.genInternalConstants()).toMatchSnapshot();
});
test('generateCCEnv', () => {
expect(cm.genCCEnv()).toMatchSnapshot();
});
test('exportStaticConstants', () => {
expect(cm.exportStaticConstants({
mode: 'PREVIEW',
platform: 'WECHAT',
flags: { DEBUG: false, SERVER_MODE: true },
})).toMatchSnapshot();
});
test('exportDynamicConstants', () => {
expect(cm.exportDynamicConstants({
mode: 'BUILD',
platform: 'WECHAT',
flags: { DEBUG: true, },
})).toMatchSnapshot();
});
test('genBuildTimeConstants', () => {
const result = cm.genBuildTimeConstants({
mode: 'TEST',
platform: 'NATIVE',
flags: { DEBUG: false, SERVER_MODE: true },
});
expect(result).toMatchInlineSnapshot(`
Object {
"ALIPAY": false,
"BAIDU": false,
"BUILD": false,
"BYTEDANCE": false,
"COCOSPLAY": false,
"DEBUG": false,
"DEV": true,
"EDITOR": false,
"HTML5": false,
"HUAWEI": false,
"JSB": true,
"LINKSURE": false,
"MINIGAME": false,
"NATIVE": true,
"NET_MODE": 0,
"NOT_PACK_PHYSX_LIBS": false,
"OPPO": false,
"PREVIEW": false,
"QTT": false,
"RUNTIME_BASED": false,
"SERVER_MODE": true,
"SUPPORT_JIT": true,
"TEST": true,
"VIVO": false,
"WECHAT": false,
"XIAOMI": false,
}
`);
});