Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/components/tests/test_Trainer.js
Show All 33 Lines | |||||
}); | }); | ||||
cmpTrainer.GetUpgradedTemplate = (template) => template; | cmpTrainer.GetUpgradedTemplate = (template) => template; | ||||
AddMock(SYSTEM_ENTITY, IID_PlayerManager, { | AddMock(SYSTEM_ENTITY, IID_PlayerManager, { | ||||
"GetPlayerByID": id => playerEntityID | "GetPlayerByID": id => playerEntityID | ||||
}); | }); | ||||
AddMock(playerEntityID, IID_Player, { | AddMock(playerEntityID, IID_Player, { | ||||
"GetCiv": () => "iber", | |||||
"GetDisabledTemplates": () => ({}), | "GetDisabledTemplates": () => ({}), | ||||
"GetPlayerID": () => playerID | "GetPlayerID": () => playerID | ||||
}); | }); | ||||
AddMock(playerEntityID, IID_Identity, { | |||||
"GetCiv": () => "iber", | |||||
}); | |||||
AddMock(entityID, IID_Ownership, { | AddMock(entityID, IID_Ownership, { | ||||
"GetOwner": () => playerID | "GetOwner": () => playerID | ||||
}); | }); | ||||
AddMock(entityID, IID_Identity, { | AddMock(entityID, IID_Identity, { | ||||
"GetCiv": () => "iber" | "GetCiv": () => "iber" | ||||
}); | }); | ||||
Show All 12 Lines | |||||
TS_ASSERT_UNEVAL_EQUALS(cmpTrainer.GetEntitiesList(), ["units/iber/support_female_citizen"]); | TS_ASSERT_UNEVAL_EQUALS(cmpTrainer.GetEntitiesList(), ["units/iber/support_female_citizen"]); | ||||
AddMock(SYSTEM_ENTITY, IID_TemplateManager, { | AddMock(SYSTEM_ENTITY, IID_TemplateManager, { | ||||
"TemplateExists": () => true, | "TemplateExists": () => true, | ||||
"GetTemplate": name => ({}) | "GetTemplate": name => ({}) | ||||
}); | }); | ||||
AddMock(playerEntityID, IID_Player, { | AddMock(playerEntityID, IID_Player, { | ||||
"GetCiv": () => "iber", | |||||
"GetDisabledTemplates": () => ({ "units/athen/infantry_swordsman_b": true }), | "GetDisabledTemplates": () => ({ "units/athen/infantry_swordsman_b": true }), | ||||
"GetPlayerID": () => playerID | "GetPlayerID": () => playerID | ||||
}); | }); | ||||
cmpTrainer.CalculateEntitiesMap(); | cmpTrainer.CalculateEntitiesMap(); | ||||
TS_ASSERT_UNEVAL_EQUALS( | TS_ASSERT_UNEVAL_EQUALS( | ||||
cmpTrainer.GetEntitiesList(), | cmpTrainer.GetEntitiesList(), | ||||
["units/iber/cavalry_javelineer_b", "units/iber/infantry_swordsman_b", "units/iber/support_female_citizen"] | ["units/iber/cavalry_javelineer_b", "units/iber/infantry_swordsman_b", "units/iber/support_female_citizen"] | ||||
); | ); | ||||
AddMock(playerEntityID, IID_Player, { | AddMock(playerEntityID, IID_Player, { | ||||
"GetCiv": () => "iber", | |||||
"GetDisabledTemplates": () => ({ "units/iber/infantry_swordsman_b": true }), | "GetDisabledTemplates": () => ({ "units/iber/infantry_swordsman_b": true }), | ||||
"GetPlayerID": () => playerID | "GetPlayerID": () => playerID | ||||
}); | }); | ||||
cmpTrainer.CalculateEntitiesMap(); | cmpTrainer.CalculateEntitiesMap(); | ||||
TS_ASSERT_UNEVAL_EQUALS( | TS_ASSERT_UNEVAL_EQUALS( | ||||
cmpTrainer.GetEntitiesList(), | cmpTrainer.GetEntitiesList(), | ||||
["units/iber/cavalry_javelineer_b", "units/iber/support_female_citizen"] | ["units/iber/cavalry_javelineer_b", "units/iber/support_female_citizen"] | ||||
); | ); | ||||
AddMock(playerEntityID, IID_Player, { | AddMock(playerEntityID, IID_Player, { | ||||
"GetCiv": () => "athen", | |||||
"GetDisabledTemplates": () => ({ "units/athen/infantry_swordsman_b": true }), | "GetDisabledTemplates": () => ({ "units/athen/infantry_swordsman_b": true }), | ||||
"GetPlayerID": () => playerID | "GetPlayerID": () => playerID | ||||
}); | }); | ||||
AddMock(playerEntityID, IID_Identity, { | |||||
"GetCiv": () => "athen", | |||||
}); | |||||
cmpTrainer.CalculateEntitiesMap(); | cmpTrainer.CalculateEntitiesMap(); | ||||
TS_ASSERT_UNEVAL_EQUALS( | TS_ASSERT_UNEVAL_EQUALS( | ||||
cmpTrainer.GetEntitiesList(), | cmpTrainer.GetEntitiesList(), | ||||
["units/athen/cavalry_javelineer_b", "units/iber/support_female_citizen"] | ["units/athen/cavalry_javelineer_b", "units/iber/support_female_citizen"] | ||||
); | ); | ||||
AddMock(playerEntityID, IID_Player, { | AddMock(playerEntityID, IID_Player, { | ||||
"GetCiv": () => "iber", | |||||
"GetDisabledTemplates": () => ({ "units/iber/infantry_swordsman_b": false }), | "GetDisabledTemplates": () => ({ "units/iber/infantry_swordsman_b": false }), | ||||
"GetPlayerID": () => playerID | "GetPlayerID": () => playerID | ||||
}); | }); | ||||
AddMock(playerEntityID, IID_Identity, { | |||||
"GetCiv": () => "iber", | |||||
}); | |||||
cmpTrainer.CalculateEntitiesMap(); | cmpTrainer.CalculateEntitiesMap(); | ||||
TS_ASSERT_UNEVAL_EQUALS( | TS_ASSERT_UNEVAL_EQUALS( | ||||
cmpTrainer.GetEntitiesList(), | cmpTrainer.GetEntitiesList(), | ||||
["units/iber/cavalry_javelineer_b", "units/iber/infantry_swordsman_b", "units/iber/support_female_citizen"] | ["units/iber/cavalry_javelineer_b", "units/iber/infantry_swordsman_b", "units/iber/support_female_citizen"] | ||||
); | ); | ||||
// Test Queuing a unit. | // Test Queuing a unit. | ||||
Show All 21 Lines | |||||
}); | }); | ||||
AddMock(SYSTEM_ENTITY, IID_GuiInterface, { | AddMock(SYSTEM_ENTITY, IID_GuiInterface, { | ||||
"PushNotification": () => {}, | "PushNotification": () => {}, | ||||
"SetSelectionDirty": () => {} | "SetSelectionDirty": () => {} | ||||
}); | }); | ||||
const cmpPlayer = AddMock(playerEntityID, IID_Player, { | const cmpPlayer = AddMock(playerEntityID, IID_Player, { | ||||
"BlockTraining": () => {}, | "BlockTraining": () => {}, | ||||
"GetCiv": () => "iber", | |||||
"GetPlayerID": () => playerID, | "GetPlayerID": () => playerID, | ||||
"RefundResources": (resources) => { | "RefundResources": (resources) => { | ||||
TS_ASSERT_UNEVAL_EQUALS(resources, cost); | TS_ASSERT_UNEVAL_EQUALS(resources, cost); | ||||
}, | }, | ||||
"TrySubtractResources": (resources) => { | "TrySubtractResources": (resources) => { | ||||
TS_ASSERT_UNEVAL_EQUALS(resources, cost); | TS_ASSERT_UNEVAL_EQUALS(resources, cost); | ||||
// Just have enough resources. | // Just have enough resources. | ||||
return true; | return true; | ||||
▲ Show 20 Lines • Show All 154 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator