"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const core_1 = require("@vived/core");
const Entities_1 = require("../Entities");
const ActiveModelPM_1 = require("./ActiveModelPM");
function makeTestRig() {
    const appObjects = (0, core_1.makeAppObjectRepo)();
    const registerSpy = jest.spyOn(appObjects, "registerSingleton");
    const demo = appObjects.getOrCreate("demo");
    const repo = (0, Entities_1.makeChannelModelRepo)(demo);
    const activeModelPM = (0, ActiveModelPM_1.makeActiveModelPM)(demo);
    return { repo, activeModelPM, appObjects, registerSpy };
}
describe("Demo App Presentation Manager", () => {
    it("Gets the singleton", () => {
        const { activeModelPM, appObjects } = makeTestRig();
        expect(ActiveModelPM_1.ActiveModelPM.get(appObjects)).toEqual(activeModelPM);
    });
    it("Registers as the singleton", () => {
        const { activeModelPM, registerSpy } = makeTestRig();
        expect(registerSpy).toHaveBeenCalledWith(activeModelPM);
    });
    it("Initializes correctly", () => {
        const { activeModelPM } = makeTestRig();
        expect(activeModelPM.lastVM).toEqual("");
    });
    it("Updates when the entity changes", () => {
        const { activeModelPM, repo } = makeTestRig();
        expect(activeModelPM.lastVM).toEqual("");
        repo.activeModel = "modelID";
        expect(activeModelPM.lastVM).toEqual("modelID");
    });
    it("Compares the VM", () => {
        const { activeModelPM } = makeTestRig();
        expect(activeModelPM.vmsAreEqual("", "")).toEqual(true);
        expect(activeModelPM.vmsAreEqual("modelID", "modelID")).toEqual(true);
        expect(activeModelPM.vmsAreEqual("", "modelID")).toEqual(false);
        expect(activeModelPM.vmsAreEqual("modelID", "")).toEqual(false);
    });
});
//# sourceMappingURL=ActiveModelPM.test.js.map