"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const core_1 = require("@vived/core");
const core_2 = require("@vived/core");
const ZSpaceDisplayEntity_1 = require("./ZSpaceDisplayEntity");
function makeTestRig() {
    const appOjects = (0, core_1.makeAppObjectRepo)();
    const displayAO = appOjects.getOrCreate("ZSpace Display");
    const displayEntity = (0, ZSpaceDisplayEntity_1.makeZSpaceDisplayEntity)(displayAO);
    const observer = jest.fn();
    displayEntity.addChangeObserver(observer);
    return { appOjects, displayAO, displayEntity, observer };
}
describe("ZSpace Display Entity", () => {
    it("Notifies when the display size changes", () => {
        const { displayEntity, observer } = makeTestRig();
        displayEntity.displaySizeMeters = new core_2.Vector2(1, 2);
        displayEntity.displaySizeMeters = new core_2.Vector2(1, 2);
        displayEntity.displaySizeMeters = new core_2.Vector2(1, 2);
        expect(observer).toHaveBeenCalledTimes(1);
        expect(displayEntity.displaySizeMeters).toEqual(new core_2.Vector2(1, 2));
    });
    it("Notifies when the pixel size changes", () => {
        const { displayEntity, observer } = makeTestRig();
        displayEntity.displaySizePixels = new core_2.Vector2(1, 2);
        displayEntity.displaySizePixels = new core_2.Vector2(1, 2);
        displayEntity.displaySizePixels = new core_2.Vector2(1, 2);
        expect(observer).toHaveBeenCalledTimes(1);
        expect(displayEntity.displaySizePixels).toEqual(new core_2.Vector2(1, 2));
    });
    it("Calculates meters per pixel", () => {
        const { displayEntity } = makeTestRig();
        displayEntity.displaySizeMeters = new core_2.Vector2(2, 2);
        displayEntity.displaySizePixels = new core_2.Vector2(200, 100);
        expect(displayEntity.metersPerPixel).toEqual(2 / 200);
    });
    it("Returns zero meters per pixel if the pixel size is zero", () => {
        const { displayEntity } = makeTestRig();
        displayEntity.displaySizeMeters = new core_2.Vector2(2, 2);
        displayEntity.displaySizePixels = core_2.Vector2.Zero();
        expect(displayEntity.metersPerPixel).toEqual(0);
    });
    it("Calculates pixel per meter", () => {
        const { displayEntity } = makeTestRig();
        displayEntity.displaySizeMeters = new core_2.Vector2(2, 2);
        displayEntity.displaySizePixels = new core_2.Vector2(200, 100);
        expect(displayEntity.pixelPerMeter).toEqual(200 / 2);
    });
    it("Returns zero pixels per meters if the meter size is zero", () => {
        const { displayEntity } = makeTestRig();
        displayEntity.displaySizePixels = new core_2.Vector2(2, 2);
        displayEntity.displaySizeMeters = core_2.Vector2.Zero();
        expect(displayEntity.pixelPerMeter).toEqual(0);
    });
    it("Sets up the Mako", () => {
        const { displayEntity } = makeTestRig();
        displayEntity.setForDevice(ZSpaceDisplayEntity_1.ZSpaceDevice.MAKO);
        expect(displayEntity.displaySizeMeters).toEqual(new core_2.Vector2(0.344, 0.193));
        expect(displayEntity.displaySizePixels).toEqual(new core_2.Vector2(1920, 1080));
    });
    it("Sets up the Inspire", () => {
        const { displayEntity } = makeTestRig();
        displayEntity.setForDevice(ZSpaceDisplayEntity_1.ZSpaceDevice.INSPIRE);
        expect(displayEntity.displaySizeMeters).toEqual(new core_2.Vector2(0.344, 0.193));
        expect(displayEntity.displaySizePixels).toEqual(new core_2.Vector2(1920, 1080));
    });
    it("Sets up the AIO", () => {
        const { displayEntity } = makeTestRig();
        displayEntity.setForDevice(ZSpaceDisplayEntity_1.ZSpaceDevice.AIO);
        expect(displayEntity.displaySizeMeters).toEqual(new core_2.Vector2(0.521, 0.293));
        expect(displayEntity.displaySizePixels).toEqual(new core_2.Vector2(1920, 1080));
    });
});
//# sourceMappingURL=ZSpaceDisplayEntity.test.js.map