Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/globalscripts/tests/test_AttackEffects.js
let effects = { | const effects = { | ||||
"eff_A": { | "eff_A": { | ||||
"code": "a", | "code": "a", | ||||
"name": "A", | "name": "A", | ||||
"order": "2", | "order": "2", | ||||
"cmp": "A", | |||||
"IID": "IID_A", | "IID": "IID_A", | ||||
"method": "doA" | "method": "doA", | ||||
"getRelativeEffectMethod": "getA" | |||||
}, | }, | ||||
"eff_B": { | "eff_B": { | ||||
"code": "b", | "code": "b", | ||||
"name": "B", | "name": "B", | ||||
"order": "1", | "order": "1", | ||||
"cmp": "B", | |||||
"IID": "IID_B", | "IID": "IID_B", | ||||
"method": "doB" | "method": "doB", | ||||
"getRelativeEffectMethod": "getB" | |||||
} | } | ||||
}; | }; | ||||
Engine.ListDirectoryFiles = () => Object.keys(effects); | Engine.ListDirectoryFiles = () => Object.keys(effects); | ||||
Engine.ReadJSONFile = (file) => effects[file]; | Engine.ReadJSONFile = (file) => effects[file]; | ||||
let attackEffects = new AttackEffects(); | const attackEffects = new AttackEffects(); | ||||
TS_ASSERT_UNEVAL_EQUALS(attackEffects.Receivers(), [{ | TS_ASSERT_UNEVAL_EQUALS(attackEffects.Receivers(), [{ | ||||
"type": "b", | "type": "b", | ||||
"cmp": "B", | |||||
"IID": "IID_B", | "IID": "IID_B", | ||||
"method": "doB" | "method": "doB", | ||||
"getRelativeEffectMethod": "getB" | |||||
}, { | }, { | ||||
"type": "a", | "type": "a", | ||||
"cmp": "A", | |||||
"IID": "IID_A", | "IID": "IID_A", | ||||
"method": "doA" | "method": "doA", | ||||
"getRelativeEffectMethod": "getA" | |||||
}]); | }]); | ||||
TS_ASSERT_UNEVAL_EQUALS(attackEffects.Codes(), ["b", "a"]); | |||||
TS_ASSERT_UNEVAL_EQUALS(attackEffects.GetReceiverFromCode("b"), { | |||||
"type": "b", | |||||
"cmp": "B", | |||||
"IID": "IID_B", | |||||
"method": "doB", | |||||
"getRelativeEffectMethod": "getB" | |||||
}); | |||||
TS_ASSERT_UNEVAL_EQUALS(attackEffects.GetReceiverFromCode("c"), undefined); |
Wildfire Games · Phabricator