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

30 lines
1.1 KiB
TypeScript
Raw Normal View History

module TS.SpaceTac.UI.Specs {
describe("Tooltip", () => {
let testgame = setupEmptyView();
it("shows near the hovered button", function () {
let button = testgame.baseview.add.button();
spyOn(button, "getBounds").and.returnValue({ x: 100, y: 50, width: 50, height: 25 });
let tooltip = new Tooltip(testgame.baseview);
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 });
expect(container.visible).toBe(false);
button.onInputOver.dispatch();
expect(container.visible).toBe(false);
jasmine.clock().tick(1000);
container.update();
expect(container.visible).toBe(true);
2017-05-15 23:20:35 +00:00
expect(container.x).toEqual(109);
expect(container.y).toEqual(91);
button.onInputOut.dispatch();
expect(container.visible).toBe(false);
});
});
}