1
0
Fork 0
spacetac/src/core/actions/EndTurnAction.spec.ts

31 lines
1.1 KiB
TypeScript
Raw Normal View History

2017-09-24 22:23:22 +00:00
module TK.SpaceTac.Specs {
2017-10-26 21:47:13 +00:00
testing("EndTurnAction", test => {
test.case("can't be applied to non-playing ship", check => {
spyOn(console, "warn").and.stub();
2017-09-19 15:09:06 +00:00
let battle = Battle.newQuickRandom();
let action = new EndTurnAction();
2015-01-07 00:00:00 +00:00
2017-10-26 21:47:13 +00:00
check.equals(action.checkCannotBeApplied(battle.play_order[0]), null);
check.equals(action.checkCannotBeApplied(battle.play_order[1]), "ship not playing");
2015-01-07 00:00:00 +00:00
2017-09-19 15:09:06 +00:00
let ship = battle.play_order[1];
let result = action.apply(battle.play_order[1]);
2017-10-26 21:47:13 +00:00
check.equals(result, false);
2017-09-19 15:09:06 +00:00
expect(console.warn).toHaveBeenCalledWith("Action rejected - ship not playing", ship, action, Target.newFromShip(ship));
2015-01-07 00:00:00 +00:00
});
2017-10-26 21:47:13 +00:00
test.case("ends turn when applied", check => {
2017-09-19 15:09:06 +00:00
let battle = Battle.newQuickRandom();
let action = new EndTurnAction();
2015-01-07 00:00:00 +00:00
2017-10-26 21:47:13 +00:00
check.equals(battle.play_index, 0);
2015-01-07 00:00:00 +00:00
2017-09-19 15:09:06 +00:00
let result = action.apply(battle.play_order[0], Target.newFromShip(battle.play_order[0]));
2017-10-26 21:47:13 +00:00
check.equals(result, true);
check.equals(battle.play_index, 1);
2015-01-07 00:00:00 +00:00
});
});
}