1
0
Fork 0
spacetac/src/scripts/view/specs/TestGame.ts

35 lines
1.1 KiB
TypeScript
Raw Normal View History

2015-01-08 00:00:00 +00:00
/// <reference path="../../definitions/jasmine.d.ts"/>
module SpaceTac.View.Specs {
"use strict";
// Test game wrapper (use instead of jasmine 'it')
2015-01-08 00:00:00 +00:00
export function ingame_it(desc: string, func: (game: Phaser.Game, state: Phaser.State) => void,
state: Phaser.State = null, ...stateargs: any[]) {
2015-01-08 00:00:00 +00:00
it(desc, (done: () => void) => {
var game = new Phaser.Game(500, 500, Phaser.HEADLESS);
2015-01-08 00:00:00 +00:00
if (!state) {
state = new Phaser.State();
}
var orig_create = state.create;
2015-01-09 00:00:00 +00:00
state.create = function () {
2015-01-08 00:00:00 +00:00
orig_create.apply(state);
func(game, state);
done();
2015-01-09 00:00:00 +00:00
setTimeout(() => {
game.destroy();
}, 1000);
2015-01-08 00:00:00 +00:00
};
game.state.add("test", state);
var args = stateargs.slice(0);
args.unshift(true);
args.unshift(true);
args.unshift("test");
game.state.start.apply(game.state, args);
2015-01-08 00:00:00 +00:00
});
}
}