import { makeAppObjectRepo } from "@vived/core";
import { makeCalloutRepoEntity } from "../Entities/CalloutRepo";
import { CalloutListPM, makeCalloutListPM } from "./CalloutListPM";
function makeTestRig() {
    const appObjects = makeAppObjectRepo();
    const appObj = appObjects.getOrCreate("repo");
    const repo = makeCalloutRepoEntity(appObj);
    repo.makeCallout("callout1");
    const pm = makeCalloutListPM(appObj);
    const view = jest.fn();
    pm.addView(view);
    return { appObj, appObjects, repo, pm, view };
}
describe("Callout List Presentation Manager", () => {
    it("Gets the PM", () => {
        const { appObjects, pm } = makeTestRig();
        expect(CalloutListPM.getById("repo", appObjects)).toEqual(pm);
    });
    it("Sets the last vm on construction", () => {
        const { pm } = makeTestRig();
        expect(pm.lastVM).not.toBeUndefined();
        expect(pm.lastVM).toEqual(["callout1"]);
    });
    it("Updates the view when the repo changes", () => {
        const { pm, repo } = makeTestRig();
        repo.makeCallout("another Callout");
        expect(pm.lastVM).toEqual(["callout1", "another Callout"]);
    });
    it("Returns true if the VMs are the same", () => {
        const { pm } = makeTestRig();
        const vm1 = ["appObj1"];
        const vm2 = ["appObj1"];
        expect(pm.vmsAreEqual(vm1, vm2)).toEqual(true);
    });
    it("Returns false if an object is added", () => {
        const { pm } = makeTestRig();
        const vm1 = ["appObj1"];
        const vm2 = ["appObj1", "appObj2"];
        expect(pm.vmsAreEqual(vm1, vm2)).toEqual(false);
    });
    it("Returns false if an object is removed", () => {
        const { pm } = makeTestRig();
        const vm1 = ["appObj1", "appObj2"];
        const vm2 = ["appObj1"];
        expect(pm.vmsAreEqual(vm1, vm2)).toEqual(false);
    });
    it("Returns false if an id changes", () => {
        const { pm } = makeTestRig();
        const vm1 = ["appObj1", "appObj2"];
        const vm2 = ["appObj1", "CHANGED"];
        expect(pm.vmsAreEqual(vm1, vm2)).toEqual(false);
    });
});
//# sourceMappingURL=CalloutListPM.test.js.map