1
0
Fork 0
spacetac/src/ui/common/Tooltip.spec.ts

31 lines
1.1 KiB
TypeScript
Raw Normal View History

2017-09-24 22:23:22 +00:00
module TK.SpaceTac.UI.Specs {
2017-10-26 21:47:13 +00:00
testing("Tooltip", test => {
let testgame = setupEmptyView();
2017-10-26 21:47:13 +00:00
let clock = test.clock();
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();
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);
tooltip.bind(button, filler => true);
let container = <Phaser.Group>(<any>tooltip).container;
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);
button.onInputOver.dispatch();
2017-10-26 21:47:13 +00:00
check.equals(container.visible, false);
2017-10-26 21:47:13 +00:00
clock.forward(1000);
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);
button.onInputOut.dispatch();
2017-10-26 21:47:13 +00:00
check.equals(container.visible, false);
});
});
}