"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const core_1 = require("@vived/core");
const core_2 = require("@vived/core");
const ZSpaceDisplayEntity_1 = require("../Entities/ZSpaceDisplayEntity");
const ZSpaceEntity_1 = require("../Entities/ZSpaceEntity");
const ZSpaceDisplayPM_1 = require("./ZSpaceDisplayPM");
function makeTestRig() {
    const appObjects = (0, core_1.makeAppObjectRepo)();
    const registerSpy = jest.spyOn(appObjects, "registerSingleton");
    const zSpace = appObjects.getOrCreate("zSpace");
    const zSpaceEntity = (0, ZSpaceEntity_1.makeZSpaceEntity)(zSpace);
    const displayEntity = zSpaceEntity.display;
    displayEntity.setForDevice(ZSpaceDisplayEntity_1.ZSpaceDevice.INSPIRE);
    const pm = (0, ZSpaceDisplayPM_1.makeZSpaceDisplayPM)(displayEntity.appObject);
    return { zSpaceEntity, pm, displayEntity, registerSpy, appObjects };
}
describe("ZSpace Display Presentation Manager", () => {
    it("Initializes the VM", () => {
        const { pm } = makeTestRig();
        expect(pm.lastVM).not.toBeUndefined();
    });
    it("Sets the show based on the is rendering flag", () => {
        const { pm, zSpaceEntity } = makeTestRig();
        zSpaceEntity.enabled = false;
        expect(pm.lastVM?.show).toEqual(false);
        zSpaceEntity.enabled = true;
        expect(pm.lastVM?.show).toEqual(true);
    });
    it("Checks for equal vms", () => {
        const { pm } = makeTestRig();
        const vm1 = {
            pixelSize: new core_2.Vector2(1, 2),
            show: true,
            worldSize: new core_2.Vector2(3, 4),
        };
        const vm2 = {
            pixelSize: new core_2.Vector2(1, 2),
            show: true,
            worldSize: new core_2.Vector2(3, 4),
        };
        expect(pm.vmsAreEqual(vm1, vm2)).toEqual(true);
    });
    it("Checks for a change in the show flag", () => {
        const { pm } = makeTestRig();
        const vm1 = {
            pixelSize: new core_2.Vector2(1, 2),
            show: true,
            worldSize: new core_2.Vector2(3, 4),
        };
        const vm2 = {
            pixelSize: new core_2.Vector2(1, 2),
            show: false,
            worldSize: new core_2.Vector2(3, 4),
        };
        expect(pm.vmsAreEqual(vm1, vm2)).toEqual(false);
    });
    it("Checks for a change in the pixel size", () => {
        const { pm } = makeTestRig();
        const vm1 = {
            pixelSize: new core_2.Vector2(1, 2),
            show: true,
            worldSize: new core_2.Vector2(3, 4),
        };
        const vm2 = {
            pixelSize: new core_2.Vector2(2, 3),
            show: true,
            worldSize: new core_2.Vector2(3, 4),
        };
        expect(pm.vmsAreEqual(vm1, vm2)).toEqual(false);
    });
    it("Checks for a change in the world size", () => {
        const { pm } = makeTestRig();
        const vm1 = {
            pixelSize: new core_2.Vector2(1, 2),
            show: true,
            worldSize: new core_2.Vector2(3, 4),
        };
        const vm2 = {
            pixelSize: new core_2.Vector2(1, 2),
            show: true,
            worldSize: new core_2.Vector2(5, 6),
        };
        expect(pm.vmsAreEqual(vm1, vm2)).toEqual(false);
    });
    it("Gets the singleton", () => {
        const { appObjects, pm } = makeTestRig();
        expect(ZSpaceDisplayPM_1.ZSpaceDisplayPM.get(appObjects)).toEqual(pm);
    });
    it("Registers as the singleton", () => {
        const { registerSpy, pm } = makeTestRig();
        expect(registerSpy).toHaveBeenCalledWith(pm);
    });
});
//# sourceMappingURL=ZSpaceDisplayPM.test.js.map