import { makeAppObjectRepo } from "@vived/core";
import { makeChannelModelRepo } from "../Entities";
import { ActiveModelPM, makeActiveModelPM } from "./ActiveModelPM";
function makeTestRig() {
    const appObjects = makeAppObjectRepo();
    const registerSpy = jest.spyOn(appObjects, "registerSingleton");
    const demo = appObjects.getOrCreate("demo");
    const repo = makeChannelModelRepo(demo);
    const activeModelPM = makeActiveModelPM(demo);
    return { repo, activeModelPM, appObjects, registerSpy };
}
describe("Demo App Presentation Manager", () => {
    it("Gets the singleton", () => {
        const { activeModelPM, appObjects } = makeTestRig();
        expect(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