Define variables before mentioning them in scripted component tests, and add a linter rule for this.

Patch By: Krinkle
Differential Revision: https://code.wildfiregames.com/D1986
This was SVN commit r22380.
This commit is contained in:
Nicolas Auvray 2019-06-16 20:48:28 +00:00
parent f4babd9b34
commit 4967d176b9
3 changed files with 10 additions and 9 deletions

View File

@ -36,6 +36,7 @@ let multiplier = {
"metal": 1.0
}
};
let cmpBarter = ConstructComponent(SYSTEM_ENTITY, "Barter");
AddMock(SYSTEM_ENTITY, IID_Timer, {
"CancelTimer": id => { timerActivated = false; },
@ -47,8 +48,6 @@ AddMock(SYSTEM_ENTITY, IID_Timer, {
}
});
let cmpBarter = ConstructComponent(SYSTEM_ENTITY, "Barter");
// Init
TS_ASSERT_EQUALS(cmpBarter.restoreTimer, undefined);
TS_ASSERT_UNEVAL_EQUALS(cmpBarter.priceDifferences, { "wood": 0, "stone": 0, "metal": 0 });

View File

@ -18,6 +18,13 @@ function testFoundation(...mocks)
{
ResetState();
let finalTemplate = "structures/athen_civil_centre.xml";
let foundationHP = 1;
let maxHP = 100;
let rot = new Vector3D(1, 2, 3);
let pos = new Vector2D(4, 5);
let cmpFoundation;
AddMock(SYSTEM_ENTITY, IID_Trigger, {
"CallEvent": () => {},
});
@ -40,12 +47,6 @@ function testFoundation(...mocks)
});
Engine.RegisterGlobal("MT_EntityRenamed", "entityRenamed");
let finalTemplate = "structures/athen_civil_centre.xml";
let foundationHP = 1;
let maxHP = 100;
let rot = new Vector3D(1, 2, 3);
let pos = new Vector2D(4, 5);
AddMock(foundationEnt, IID_Cost, {
"GetBuildTime": () => 50,
"GetResourceCosts": () => ({ "wood": 100 }),
@ -119,7 +120,7 @@ function testFoundation(...mocks)
TS_ASSERT_EQUALS(template, "construction|" + finalTemplate);
return previewEnt;
};
let cmpFoundation = ConstructComponent(foundationEnt, "Foundation", {});
cmpFoundation = ConstructComponent(foundationEnt, "Foundation", {});
cmpFoundation.InitialiseConstruction(player, finalTemplate);
TS_ASSERT_EQUALS(cmpFoundation.owner, player);

View File

@ -19,6 +19,7 @@
"no-negated-in-lhs": 1,
"no-obj-calls": 1,
"no-unreachable": 1,
"no-use-before-define": ["error", "nofunc"],
"use-isnan": 1,
"valid-jsdoc": 0,
"valid-typeof": 1,