2017-09-24 22:23:22 +00:00
|
|
|
module TK.SpaceTac.Specs {
|
2017-10-26 21:47:13 +00:00
|
|
|
testing("BattleCheats", test => {
|
|
|
|
test.case("wins a battle", check => {
|
2017-08-17 17:51:22 +00:00
|
|
|
let battle = Battle.newQuickRandom();
|
|
|
|
|
|
|
|
battle.cheats.win();
|
2017-10-26 21:47:13 +00:00
|
|
|
check.same(battle.ended, true, "ended");
|
|
|
|
check.same(battle.outcome.winner, battle.fleets[0], "winner");
|
|
|
|
check.equals(battle.log.events.filter(event => event instanceof DeathEvent).map(event => event.ship), battle.fleets[1].ships, "all mark dead");
|
|
|
|
check.same(any(battle.fleets[1].ships, ship => !ship.alive), false, "all restored");
|
2017-08-17 17:51:22 +00:00
|
|
|
})
|
|
|
|
|
2017-10-26 21:47:13 +00:00
|
|
|
test.case("loses a battle", check => {
|
2017-08-17 17:51:22 +00:00
|
|
|
let battle = Battle.newQuickRandom();
|
|
|
|
|
|
|
|
battle.cheats.lose();
|
2017-10-26 21:47:13 +00:00
|
|
|
check.same(battle.ended, true, "ended");
|
|
|
|
check.same(battle.outcome.winner, battle.fleets[1], "winner");
|
|
|
|
check.equals(battle.log.events.filter(event => event instanceof DeathEvent).map(event => event.ship), battle.fleets[0].ships, "all mark dead");
|
|
|
|
check.same(any(battle.fleets[0].ships, ship => !ship.alive), false, "all restored");
|
2017-08-17 17:51:22 +00:00
|
|
|
})
|
|
|
|
|
2017-10-26 21:47:13 +00:00
|
|
|
test.case("adds an equipment", check => {
|
2017-08-17 17:51:22 +00:00
|
|
|
let battle = new Battle();
|
2017-10-25 22:45:53 +00:00
|
|
|
let ship = new Ship();
|
|
|
|
TestTools.setShipPlaying(battle, ship);
|
|
|
|
ship.upgradeSkill("skill_materials");
|
2017-08-17 17:51:22 +00:00
|
|
|
|
2017-10-26 21:47:13 +00:00
|
|
|
check.equals(ship.listEquipment(), []);
|
2017-08-17 17:51:22 +00:00
|
|
|
battle.cheats.equip("Iron Hull");
|
2017-10-26 21:47:13 +00:00
|
|
|
check.equals(ship.listEquipment(), [<any>jasmine.objectContaining({ name: "Iron Hull", level: 1 })]);
|
2017-08-17 17:51:22 +00:00
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|