2017-09-24 22:23:22 +00:00
|
|
|
module TK.SpaceTac.UI.Specs {
|
2017-10-26 21:47:13 +00:00
|
|
|
testing("Tooltip", test => {
|
2017-04-19 21:34:11 +00:00
|
|
|
let testgame = setupEmptyView();
|
2017-10-26 21:47:13 +00:00
|
|
|
let clock = test.clock();
|
2017-04-19 21:34:11 +00:00
|
|
|
|
2017-10-26 21:47:13 +00:00
|
|
|
test.case("shows near the hovered button", check => {
|
2017-10-09 21:13:56 +00:00
|
|
|
let button = testgame.view.add.button();
|
2017-04-19 21:34:11 +00:00
|
|
|
spyOn(button, "getBounds").and.returnValue({ x: 100, y: 50, width: 50, height: 25 });
|
|
|
|
|
2017-10-09 21:13:56 +00:00
|
|
|
let tooltip = new Tooltip(testgame.view);
|
2017-07-11 22:56:06 +00:00
|
|
|
tooltip.bind(button, filler => true);
|
2017-04-19 21:34:11 +00:00
|
|
|
|
|
|
|
let container = <Phaser.Group>(<any>tooltip).container;
|
2017-07-11 22:56:06 +00:00
|
|
|
spyOn((<any>container).content, "getBounds").and.returnValue({ x: 0, y: 0, width: 32, height: 32 });
|
2017-10-26 21:47:13 +00:00
|
|
|
check.equals(container.visible, false);
|
2017-04-19 21:34:11 +00:00
|
|
|
|
|
|
|
button.onInputOver.dispatch();
|
2017-10-26 21:47:13 +00:00
|
|
|
check.equals(container.visible, false);
|
2017-04-19 21:34:11 +00:00
|
|
|
|
2017-10-26 21:47:13 +00:00
|
|
|
clock.forward(1000);
|
2017-04-19 21:34:11 +00:00
|
|
|
container.update();
|
2017-10-26 21:47:13 +00:00
|
|
|
check.equals(container.visible, true);
|
|
|
|
check.equals(container.x, 109);
|
|
|
|
check.equals(container.y, 91);
|
2017-04-19 21:34:11 +00:00
|
|
|
|
|
|
|
button.onInputOut.dispatch();
|
2017-10-26 21:47:13 +00:00
|
|
|
check.equals(container.visible, false);
|
2017-04-19 21:34:11 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|