1
0
Fork 0
spacetac/src/ui/map/MissionsDialog.spec.ts

60 lines
2.7 KiB
TypeScript
Raw Normal View History

2017-09-24 22:23:22 +00:00
module TK.SpaceTac.UI.Specs {
2017-10-26 21:47:13 +00:00
testing("MissionsDialog", test => {
2017-10-29 21:08:55 +00:00
let testgame = setupEmptyView(test);
2017-07-10 22:50:38 +00:00
2017-10-26 21:47:13 +00:00
test.case("displays active and proposed missions", check => {
2017-07-10 22:50:38 +00:00
let universe = new Universe();
let player = new Player();
let shop = new Shop();
let shop_missions: Mission[] = [];
2017-10-29 21:08:55 +00:00
check.patch(shop, "getMissions", () => shop_missions);
2017-07-10 22:50:38 +00:00
2017-10-26 21:47:13 +00:00
function checkTexts(dialog: MissionsDialog, expected: string[]) {
let i = 0;
let container = <Phaser.Group>(<any>dialog).container;
container.children.forEach(child => {
if (child instanceof Phaser.Text) {
check.equals(child.text, expected[i++]);
}
});
check.equals(i, expected.length);
}
2017-10-09 21:13:56 +00:00
let missions = new MissionsDialog(testgame.view, shop, player);
2017-07-10 22:50:38 +00:00
checkTexts(missions, []);
let mission = new Mission(universe);
mission.title = "Save the universe!";
mission.setDifficulty(MissionDifficulty.hard, 1);
mission.reward = 15000;
shop_missions.push(mission);
missions.refresh();
checkTexts(missions, ["Proposed jobs", "Save the universe!", "Hard - Reward: 15000 zotys"]);
mission = new Mission(universe);
mission.title = "Do not do evil";
mission.setDifficulty(MissionDifficulty.easy, 1);
mission.reward = 3500;
2017-07-10 22:50:38 +00:00
shop_missions.push(mission);
missions.refresh();
checkTexts(missions, ["Proposed jobs", "Save the universe!", "Hard - Reward: 15000 zotys", "Do not do evil", "Easy - Reward: 3500 zotys"]);
2017-07-10 22:50:38 +00:00
mission = new Mission(universe);
mission.title = "Collect some money";
mission.setDifficulty(MissionDifficulty.normal, 1);
player.missions.addSecondary(mission, player.fleet);
missions.refresh();
checkTexts(missions, ["Active jobs", "Collect some money", "Normal - Reward: -",
"Proposed jobs", "Save the universe!", "Hard - Reward: 15000 zotys", "Do not do evil", "Easy - Reward: 3500 zotys"]);
2017-07-10 22:50:38 +00:00
mission = new Mission(universe, undefined, true);
mission.title = "Kill the villain";
mission.setDifficulty(MissionDifficulty.hard, 1);
player.missions.main = mission;
missions.refresh();
checkTexts(missions, ["Active jobs", "Collect some money", "Normal - Reward: -",
"Proposed jobs", "Save the universe!", "Hard - Reward: 15000 zotys", "Do not do evil", "Easy - Reward: 3500 zotys"]);
2017-07-10 22:50:38 +00:00
});
});
}