"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 WorldHoverLabelPM_1 = require("./WorldHoverLabelPM");
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, WorldHoverLabelPM_1.makeWorldHoverLabelPM)(appObject);
    pm.addView(view);
    return { hoverLabel, view, pm, registerSpy, appObjects };
}
describe("World 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 world hover label is shown", () => {
        const { view, hoverLabel } = makeTestRig();
        view.mockClear();
        hoverLabel.showWorldHoverLabel("HoverLabel", new core_2.Vector3(50, 60, 70));
        expect(view).toHaveBeenCalledWith({
            show: true,
            text: "HoverLabel",
        });
    });
    it("Updates the view when the hover label is cleared", () => {
        const { view, hoverLabel } = makeTestRig();
        hoverLabel.showWorldHoverLabel("HoverLabel", new core_2.Vector3(50, 60, 70));
        view.mockClear();
        hoverLabel.hideHoverLabel();
        expect(view).toHaveBeenCalledWith({
            show: false,
            text: "",
        });
    });
    it("Does not show if the mode is SCREEN", () => {
        const { view, hoverLabel } = makeTestRig();
        hoverLabel.showWorldHoverLabel("New Hover Label", new core_2.Vector3(1, 2, 3));
        view.mockClear();
        hoverLabel.showScreenHoverLabel("HoverLabel", new core_2.Vector2(50, 60));
        expect(view).toHaveBeenCalledWith({
            show: false,
            text: "",
        });
    });
    it("Returns true if the VMs are the same", () => {
        const { pm } = makeTestRig();
        const vm1 = {
            show: true,
            text: "string",
        };
        const vm2 = {
            show: true,
            text: "string",
        };
        expect(pm.vmsAreEqual(vm1, vm2)).toEqual(true);
    });
    it("Returns false if the label is different", () => {
        const { pm } = makeTestRig();
        const vm1 = {
            show: true,
            text: "string1",
        };
        const vm2 = {
            show: true,
            text: "string",
        };
        expect(pm.vmsAreEqual(vm1, vm2)).toEqual(false);
    });
    it("Returns false if the show is different", () => {
        const { pm } = makeTestRig();
        const vm1 = {
            show: true,
            text: "string",
        };
        const vm2 = {
            show: false,
            text: "string",
        };
        expect(pm.vmsAreEqual(vm1, vm2)).toEqual(false);
    });
    it("Gets the PM", () => {
        const { pm, appObjects } = makeTestRig();
        expect(WorldHoverLabelPM_1.WorldHoverLabelPM.get(appObjects)).toEqual(pm);
    });
    it("Registers as the singleton", () => {
        const { pm, registerSpy } = makeTestRig();
        expect(registerSpy).toHaveBeenCalledWith(pm);
    });
});
//# sourceMappingURL=WorldHoverLabelPM.test.js.map