"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const core_1 = require("@vived/core");
const core_2 = require("@vived/core");
const HoverLabelEntity_1 = require("../Entities/HoverLabelEntity");
const ScreenHoverLabelPM_1 = require("./ScreenHoverLabelPM");
function makeTestRig() {
    const appObjects = (0, core_1.makeAppObjectRepo)();
    const registerSpy = jest.spyOn(appObjects, "registerSingleton");
    const appObject = appObjects.getOrCreate("AppObject");
    const hoverLabel = (0, HoverLabelEntity_1.makeHoverLabelEntity)(appObject);
    const view = jest.fn();
    const pm = (0, ScreenHoverLabelPM_1.makeScreenHoverLabelPM)(appObject);
    pm.addView(view);
    return { hoverLabel, view, pm, registerSpy, appObjects };
}
describe("Screen Hover Label Presentation Manager", () => {
    it("Sets the last vm on construction", () => {
        const { pm } = makeTestRig();
        expect(pm.lastVM).not.toBeUndefined();
    });
    it("Updates the view when the hover label is shown", () => {
        const { view, hoverLabel } = makeTestRig();
        view.mockClear();
        hoverLabel.showScreenHoverLabel("HoverLabel", new core_2.Vector2(50, 60));
        expect(view).toHaveBeenCalledWith({
            show: true,
            text: "HoverLabel",
            screenPosition: {
                x: 50,
                y: 60,
            },
        });
    });
    it("Updates the view when the hover label is cleared", () => {
        const { view, hoverLabel } = makeTestRig();
        hoverLabel.showScreenHoverLabel("HoverLabel", new core_2.Vector2(50, 60));
        view.mockClear();
        hoverLabel.hideHoverLabel();
        expect(view).toHaveBeenCalledWith({
            show: false,
            text: "",
            screenPosition: { x: 0, y: 0 },
        });
    });
    it("Does not show if the mode is WORLD", () => {
        const { view, hoverLabel } = makeTestRig();
        hoverLabel.showScreenHoverLabel("HoverLabel", new core_2.Vector2(50, 60));
        view.mockClear();
        hoverLabel.showWorldHoverLabel("New Hover Label", new core_2.Vector3(1, 2, 3));
        expect(view).toHaveBeenCalledWith({
            show: false,
            text: "",
            screenPosition: { x: 0, y: 0 },
        });
    });
    it("Returns true if the VMs are the same", () => {
        const { pm } = makeTestRig();
        const vm1 = {
            show: true,
            text: "string",
            screenPosition: { x: 1, y: 1 },
        };
        const vm2 = {
            show: true,
            text: "string",
            screenPosition: { x: 1, y: 1 },
        };
        expect(pm.vmsAreEqual(vm1, vm2)).toEqual(true);
    });
    it("Returns false if an object is added", () => {
        const { pm } = makeTestRig();
        const vm1 = {
            show: true,
            text: "string1",
            screenPosition: { x: 2, y: 2 },
        };
        const vm2 = {
            show: true,
            text: "string",
            screenPosition: { x: 1, y: 1 },
        };
        expect(pm.vmsAreEqual(vm1, vm2)).toEqual(false);
    });
    it("Gets the PM", () => {
        const { pm, appObjects } = makeTestRig();
        expect(ScreenHoverLabelPM_1.ScreenHoverLabelPM.get(appObjects)).toEqual(pm);
    });
    it("Registers as the singleton", () => {
        const { pm, registerSpy } = makeTestRig();
        expect(registerSpy).toHaveBeenCalledWith(pm);
    });
});
//# sourceMappingURL=ScreenHoverLabelPM.test.js.map