plaxtony
Version:
Static code analysis of SC2 Galaxy Script
72 lines • 3.75 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
require("mocha");
const chai_1 = require("chai");
const path = require("path");
const archive_1 = require("../src/sc2mod/archive");
const trig = require("../src/sc2mod/trigger");
const s2meta_1 = require("../src/service/s2meta");
const resourcesPath = path.join('tests', 'fixtures');
describe('SC2Metadata', function () {
const dir = path.resolve(path.join(resourcesPath, 'sc2-map.SC2Map'));
let s2work;
let s2meta;
before(async () => {
const sources = [
path.resolve(path.join(resourcesPath, 'sc2-data-trigger')),
];
const dir = path.resolve(path.join('tests', 'fixtures', 'sc2-map.SC2Map'));
const rootArchive = new archive_1.SC2Archive(path.basename(dir), dir);
s2work = await archive_1.openArchiveWorkspace(rootArchive, sources);
s2meta = new s2meta_1.S2WorkspaceMetadata(s2work, {
loadLevel: 'Default',
localization: 'enUS',
}, {
enabled: true,
});
await s2meta.build();
});
it('find elements by name', () => {
chai_1.assert.isDefined(s2meta.findElementByName('libLbty_gf_OrderWorkerstoGatherNearbyResources'));
chai_1.assert.isDefined(s2meta.findElementByName('gf_Action1'));
chai_1.assert.isDefined(s2meta.findElementByName('gf_action_custom_name'));
chai_1.assert.isDefined(s2meta.findElementByName('c_unitCountAll'));
chai_1.assert.isDefined(s2meta.findElementByName('libNtve_ge_FlyerHelperDisplay_c_flyerDisplaySelected'));
});
it('preset constants', () => {
const ntveLib = s2work.trigComponent.getStore().getLibraries().get('Ntve');
const flyerHelper = ntveLib.findElementById('25B4E1EC', trig.Preset);
chai_1.assert.deepEqual(s2meta.getConstantNamesOfPreset(flyerHelper), [
'libNtve_ge_FlyerHelperDisplay_c_flyerDisplayNone',
'libNtve_ge_FlyerHelperDisplay_c_flyerDisplaySelected',
'libNtve_ge_FlyerHelperDisplay_c_flyerDisplayAll',
]);
const unitDamageChangeOption = ntveLib.findElementById('6387FB6F', trig.Preset);
chai_1.assert.deepEqual(s2meta.getConstantNamesOfPreset(unitDamageChangeOption), [
'libNtve_ge_UnitDamageChangeOption_Full',
'libNtve_ge_UnitDamageChangeOption_No',
'libNtve_ge_UnitDamageChangeOption_Minimal',
'libNtve_ge_UnitDamageChangeOption_Mega',
'libNtve_ge_UnitDamageChangeOption_Mega2'
]);
});
it('find preset', () => {
const presetValue = s2meta.findElementByName('c_unitCountAll');
chai_1.assert.isDefined(s2meta.findPresetDef(presetValue));
});
it('documentation', () => {
chai_1.assert.equal(s2meta.getSymbolDoc('c_unitCountAll'), '**Any** - Unit Count Type');
chai_1.assert.equal(s2meta.getSymbolDoc('UnitCreate'), '**Create Units Facing Angle** (Create `count|Number` `type|Unit` for player `player` at `pos` facing `angle` degrees (`flags`))\n\nCreates units facing a specified angle. Use the *Last Created Unit* and *Last Created Units* functions to refer to the created units.');
});
it('documentation function args', () => {
const args = s2meta.getFunctionArgumentsDoc('UnitCreate');
chai_1.assert.equal(args.length, 6);
chai_1.assert.equal(args[0], '**Count** - `int`');
chai_1.assert.equal(args[1], '**Type** - `gamelink<Unit>`');
chai_1.assert.equal(args[2], '**Flags** - Unit Create Flags');
});
it('gamelinks', () => {
chai_1.assert.equal(s2meta.getGameLinkItem('Unit', 'AberrationACGluescreenDummy').size, 2);
});
});
//# sourceMappingURL=sc2data.js.map