Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/globalscripts/tests/test_resources.js
- This file was added.
let resources = { | |||||
"res_A": { | |||||
"code": "a", | |||||
"name": "A", | |||||
"subtypes": { | |||||
"aa": "AA", | |||||
"aaa": "AAA" | |||||
}, | |||||
"order": 2, | |||||
"properties": ["prop_a", "prop_common"] | |||||
}, | |||||
"res_B": { | |||||
"code": "b", | |||||
"name": "B", | |||||
"subtypes": { | |||||
"bb": "BB", | |||||
"bbb": "BBB" | |||||
}, | |||||
"order": 1, | |||||
"properties": ["prop_b", "prop_common"] | |||||
} | |||||
}; | |||||
Engine.ListDirectoryFiles = () => Object.keys(resources); | |||||
Engine.ReadJSONFile = (file) => resources[file]; | |||||
let res = new Resources(); | |||||
TS_ASSERT_EQUALS(res.GetResources().length, 2); | |||||
TS_ASSERT_EQUALS(res.GetResources()[0].code, "b"); | |||||
TS_ASSERT_EQUALS(res.GetResource("b").order, 1); | |||||
TS_ASSERT_UNEVAL_EQUALS(res.GetCodes(), ["b", "a"]); | |||||
TS_ASSERT_UNEVAL_EQUALS(res.GetCodes("prop_common"), ["b", "a"]); | |||||
TS_ASSERT_UNEVAL_EQUALS(res.GetCodes("prop_a"), ["a"]); | |||||
TS_ASSERT_UNEVAL_EQUALS(res.GetCodes("prop_b"), ["b"]); | |||||
TS_ASSERT_UNEVAL_EQUALS(res.GetCodes("prop_none"), []); | |||||
TS_ASSERT_UNEVAL_EQUALS(res.GetNames(), { | |||||
"a": "A", | |||||
"aa": "AA", | |||||
"aaa": "AAA", | |||||
"b": "B", | |||||
"bb": "BB", | |||||
"bbb": "BBB" | |||||
}); |
Wildfire Games · Phabricator