2017-02-09 00:00:35 +00:00
|
|
|
module TS.SpaceTac.Specs {
|
2015-01-07 00:00:00 +00:00
|
|
|
describe("EndTurnAction", () => {
|
|
|
|
it("can't be applied to non-playing ship", () => {
|
2017-03-07 19:27:46 +00:00
|
|
|
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-03-07 19:27:46 +00:00
|
|
|
expect(action.checkCannotBeApplied(battle.play_order[0])).toBe(null);
|
|
|
|
expect(action.checkCannotBeApplied(battle.play_order[1])).toBe("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]);
|
2015-01-07 00:00:00 +00:00
|
|
|
expect(result).toBe(false);
|
2017-03-07 19:27:46 +00:00
|
|
|
|
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
|
|
|
});
|
|
|
|
|
|
|
|
it("ends turn when applied", () => {
|
2017-09-19 15:09:06 +00:00
|
|
|
let battle = Battle.newQuickRandom();
|
|
|
|
let action = new EndTurnAction();
|
2015-01-07 00:00:00 +00:00
|
|
|
|
|
|
|
expect(battle.playing_ship_index).toBe(0);
|
|
|
|
|
2017-09-19 15:09:06 +00:00
|
|
|
let result = action.apply(battle.play_order[0], Target.newFromShip(battle.play_order[0]));
|
2015-01-07 00:00:00 +00:00
|
|
|
expect(result).toBe(true);
|
|
|
|
expect(battle.playing_ship_index).toBe(1);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|