mirror of
https://gitea.wildfiregames.com/0ad/0ad
synced 2026-06-17 22:03:56 -07:00
eslint --no-config-lookup --fix --rule '"prefer-const": 1' \
binaries/data/mods/public/simulation/components/tests
Ref: #7812
Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
42 lines
979 B
JavaScript
42 lines
979 B
JavaScript
Engine.LoadComponentScript("interfaces/Timer.js");
|
|
Engine.LoadComponentScript("interfaces/StatisticsTracker.js");
|
|
Engine.LoadComponentScript("StatisticsTracker.js");
|
|
|
|
AddMock(SYSTEM_ENTITY, IID_Timer, {
|
|
"SetInterval": () => true
|
|
});
|
|
|
|
Resources = {
|
|
"GetCodes": () => ["food", "metal", "stone", "wood"]
|
|
};
|
|
|
|
const cmpStatisticsTracker = ConstructComponent(SYSTEM_ENTITY, "StatisticsTracker", {
|
|
"UnitClasses": { "_string": "Infantry FishingBoat" },
|
|
"StructureClasses": { "_string": "House Wonder" }
|
|
});
|
|
|
|
const fromData = {
|
|
"successfulBribes": 3,
|
|
"unitsTrained": {
|
|
"Infantry": 5,
|
|
"Worker": 7
|
|
}
|
|
};
|
|
|
|
const toData = {
|
|
"successfulBribes": [11, 13, 17],
|
|
"unitsTrained": {
|
|
"Infantry": [19, 23],
|
|
"Worker": [29]
|
|
}
|
|
};
|
|
|
|
// This function pushes without testing for Identity classes
|
|
cmpStatisticsTracker.PushValue(fromData, toData);
|
|
TS_ASSERT_UNEVAL_EQUALS(toData, {
|
|
"successfulBribes": [11, 13, 17, 3],
|
|
"unitsTrained": {
|
|
"Infantry": [19, 23, 5],
|
|
"Worker": [29, 7]
|
|
}
|
|
});
|