"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const core_1 = require("@vived/core");
const LandmarkRepo_1 = require("../Entities/LandmarkRepo");
const LandmarkListPM_1 = require("./LandmarkListPM");
function makeTestRig() {
    const appObjects = (0, core_1.makeAppObjectRepo)();
    const appObj = appObjects.getOrCreate("appObj");
    const repo = (0, LandmarkRepo_1.makeLandmarkRepoEntity)(appObj);
    repo.createLandmark("Landmark");
    const pm = (0, LandmarkListPM_1.makeLandmarkListPM)(appObj);
    const view = jest.fn();
    pm.addView(view);
    return { appObj, appObjects, repo, pm, view };
}
describe("Landmark List Presentation Manager", () => {
    it("Gets the PM", () => {
        const { appObjects, pm } = makeTestRig();
        expect(LandmarkListPM_1.LandmarkListPM.get("appObj", appObjects)).toEqual(pm);
    });
    it("Sets the last vm on construction", () => {
        const { pm } = makeTestRig();
        expect(pm.lastVM).not.toBeUndefined();
    });
    it("Updates the view when the repo changes", () => {
        const { pm, repo } = makeTestRig();
        repo.createLandmark("Another Landmark");
        expect(pm.lastVM).toEqual(["Landmark", "Another Landmark"]);
    });
    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 re,oved", () => {
        const { pm } = makeTestRig();
        const vm1 = ["appObj1", "appObj2"];
        const vm2 = ["appObj1"];
        expect(pm.vmsAreEqual(vm1, vm2)).toEqual(false);
    });
});
//# sourceMappingURL=LandmarkListPM.test.js.map