From 59e7320a49841f83ca72147cb14ec1dd3cda9097 Mon Sep 17 00:00:00 2001 From: Imarok Date: Sun, 18 Feb 2018 10:50:06 +0000 Subject: [PATCH] Small StatisticsTracker test Reviewed by: elexis Differential Revision: https://code.wildfiregames.com/D1305 This was SVN commit r21250. --- .../tests/test_StatisticsTracker.js | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 binaries/data/mods/public/simulation/components/tests/test_StatisticsTracker.js diff --git a/binaries/data/mods/public/simulation/components/tests/test_StatisticsTracker.js b/binaries/data/mods/public/simulation/components/tests/test_StatisticsTracker.js new file mode 100644 index 0000000000..3242496edc --- /dev/null +++ b/binaries/data/mods/public/simulation/components/tests/test_StatisticsTracker.js @@ -0,0 +1,36 @@ +Engine.LoadComponentScript("StatisticsTracker.js"); +Engine.LoadComponentScript("interfaces/StatisticsTracker.js"); +Engine.LoadComponentScript("interfaces/Timer.js"); + +AddMock(SYSTEM_ENTITY, IID_Timer, { + "SetInterval": () => true +}); + +Resources = { + "GetCodes": () => ["food", "metal", "stone", "wood"] +}; + +let cmpStatisticsTracker = ConstructComponent(SYSTEM_ENTITY, "StatisticsTracker"); +let obj1 = { + "successfulBribes": 3, + "unitsTrained": { + "Infantry": 5, + "Worker": 7 + } +}; +let obj2 = { + "successfulBribes": [11, 13, 17], + "unitsTrained": { + "Infantry": [19, 23], + "Worker": 29 + } +}; + +cmpStatisticsTracker.PushValue(obj1, obj2); +TS_ASSERT_UNEVAL_EQUALS(obj2, { + "successfulBribes": [11, 13, 17, 3], + "unitsTrained": { + "Infantry": [19, 23, 5], + "Worker": [7] + } +});