mirror of
https://gitea.wildfiregames.com/0ad/0ad
synced 2026-06-19 14:53:56 -07:00
eslint --no-config-lookup --fix --rule '"prefer-const": 1' \
binaries/data/mods/public/globalscripts
Ref: #7812
Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
46 lines
962 B
JavaScript
46 lines
962 B
JavaScript
const resources = {
|
|
"res_A": {
|
|
"code": "a",
|
|
"name": "A",
|
|
"subtypes": {
|
|
"aa": "AA",
|
|
"aaa": "AAA"
|
|
},
|
|
"order": 2,
|
|
"properties": ["barterable", "tributable"]
|
|
},
|
|
"res_B": {
|
|
"code": "b",
|
|
"name": "B",
|
|
"subtypes": {
|
|
"bb": "BB",
|
|
"bbb": "BBB"
|
|
},
|
|
"order": 1,
|
|
"properties": ["tributable"]
|
|
}
|
|
};
|
|
|
|
Engine.ListDirectoryFiles = () => Object.keys(resources);
|
|
Engine.ReadJSONFile = (file) => resources[file];
|
|
|
|
const 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.GetTributableCodes(), ["b", "a"]);
|
|
TS_ASSERT_UNEVAL_EQUALS(res.GetBarterableCodes(), ["a"]);
|
|
TS_ASSERT_UNEVAL_EQUALS(res.GetTradableCodes(), []);
|
|
|
|
TS_ASSERT_UNEVAL_EQUALS(res.GetNames(), {
|
|
"a": "A",
|
|
"aa": "AA",
|
|
"aaa": "AAA",
|
|
"b": "B",
|
|
"bb": "BB",
|
|
"bbb": "BBB"
|
|
});
|