"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const core_1 = require("@vived/core");
const ZSpaceEntity_1 = require("./ZSpaceEntity");
const ZSpaceViewEntity_1 = require("./ZSpaceViewEntity");
function makeTestRig() {
    const appObjects = (0, core_1.makeAppObjectRepo)();
    const zSpaceAO = appObjects.getOrCreate("zSpace");
    const zSpace = (0, ZSpaceEntity_1.makeZSpaceEntity)(zSpaceAO);
    const observer = jest.fn();
    zSpace.addChangeObserver(observer);
    return { zSpace, observer, appObjects };
}
describe("ZSpace Entity", () => {
    it("Notifies when the enabled flag changes", () => {
        const { zSpace, observer } = makeTestRig();
        expect(zSpace.enabled).toEqual(false);
        zSpace.enabled = true;
        expect(observer).toHaveBeenCalled();
        expect(zSpace.enabled).toEqual(true);
    });
    it("Does not notify if there is no change in the enabled flag when it is set", () => {
        const { zSpace, observer } = makeTestRig();
        expect(zSpace.enabled).toEqual(false);
        zSpace.enabled = false;
        zSpace.enabled = false;
        zSpace.enabled = false;
        expect(observer).not.toHaveBeenCalled();
    });
    it("Notifies when the emulate flag changes", () => {
        const { zSpace, observer } = makeTestRig();
        expect(zSpace.emulate).toEqual(false);
        zSpace.emulate = true;
        expect(observer).toHaveBeenCalled();
        expect(zSpace.emulate).toEqual(true);
    });
    it("Does not notify if there is no change in the emulate flag when it is set", () => {
        const { zSpace, observer } = makeTestRig();
        expect(zSpace.emulate).toEqual(false);
        zSpace.emulate = false;
        zSpace.emulate = false;
        zSpace.emulate = false;
        expect(observer).not.toHaveBeenCalled();
    });
    it("Allows an observer to be removed", () => {
        const { zSpace, observer } = makeTestRig();
        zSpace.removeChangeObserver(observer);
        expect(zSpace.enabled).toEqual(false);
        zSpace.enabled = true;
        expect(observer).not.toHaveBeenCalled();
    });
    it("Gets the zSpace Entity", () => {
        const { zSpace, appObjects } = makeTestRig();
        expect(ZSpaceEntity_1.ZSpaceEntity.get(appObjects)).toEqual(zSpace);
    });
    it("Sets up the views correctly", () => {
        const { zSpace } = makeTestRig();
        expect(zSpace.headView.viewType).toEqual(ZSpaceViewEntity_1.ZSpaceViewType.CENTER);
        expect(zSpace.leftEyeView.viewType).toEqual(ZSpaceViewEntity_1.ZSpaceViewType.LEFT);
        expect(zSpace.rightEyeView.viewType).toEqual(ZSpaceViewEntity_1.ZSpaceViewType.RIGHT);
    });
    it("Notifies when the is supported flag changes", () => {
        const { zSpace, observer } = makeTestRig();
        expect(zSpace.isSupported).toEqual(false);
        zSpace.isSupported = true;
        expect(observer).toHaveBeenCalled();
        expect(zSpace.isSupported).toEqual(true);
    });
    it("Does not notify if there is no change in the is supported flag when it is set", () => {
        const { zSpace, observer } = makeTestRig();
        expect(zSpace.isSupported).toEqual(false);
        zSpace.isSupported = false;
        zSpace.isSupported = false;
        zSpace.isSupported = false;
        expect(observer).not.toHaveBeenCalled();
    });
});
//# sourceMappingURL=ZSpaceEntity.test.js.map