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 => {
2017-10-29 21:08:55 +00:00
let testgame = setupEmptyView(test);
2017-10-26 21:47:13 +00:00
test.case("shows near the hovered button", check => {
2018-05-15 14:57:45 +00:00
let button = new UIBuilder(testgame.view).button("fake");
check.patch(button, "getBounds", () => new Phaser.Geom.Rectangle(100, 50, 50, 25));
2017-10-09 21:13:56 +00:00
let tooltip = new Tooltip(testgame.view);
tooltip.bind(button, filler => true);
2018-05-15 14:57:45 +00:00
let container = tooltip.container;
check.patch(container.content, "getBounds", () => new Phaser.Geom.Rectangle(0, 0, 32, 32));
2017-10-26 21:47:13 +00:00
check.equals(container.visible, false);
2018-05-15 14:57:45 +00:00
let pointer = {};
button.emit("pointerover", { pointer: pointer });
2017-10-26 21:47:13 +00:00
check.equals(container.visible, false);
testgame.clockForward(1000);
container.update();
2017-10-26 21:47:13 +00:00
check.equals(container.visible, true);
2018-05-15 14:57:45 +00:00
check.equals(container.x, 113);
2017-10-26 21:47:13 +00:00
check.equals(container.y, 91);
2018-05-15 14:57:45 +00:00
button.emit("pointerout", { pointer: pointer });
2017-10-26 21:47:13 +00:00
check.equals(container.visible, false);
});
});
}