"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const core_1 = require("@vived/core");
const CalloutRepo_1 = require("../../Callouts/Entities/CalloutRepo");
const Entities_1 = require("../Entities");
const ModelHasCalloutsPM_1 = require("./ModelHasCalloutsPM");
function makeTestRig() {
    const appObjects = (0, core_1.makeAppObjectRepo)();
    const appObj = appObjects.getOrCreate("appObj");
    const model = (0, Entities_1.makeChannelModelEntity)(appObj);
    const pm = (0, ModelHasCalloutsPM_1.makeModelHasCalloutsPM)(appObj);
    const modelObj = model.addModelObject();
    const repo = (0, CalloutRepo_1.makeCalloutRepoEntity)(modelObj.appObject);
    repo.addChangeObserver(modelObj.notifyOnChange);
    return { appObj, appObjects, pm, repo };
}
describe("Model Objects have Callouts PM", () => {
    it("Sets the last vm on construction", () => {
        const { pm } = makeTestRig();
        expect(pm.lastVM).not.toBeUndefined();
    });
    it("Updates when a callout is added", () => {
        const { pm, repo } = makeTestRig();
        expect(pm.lastVM).toEqual(false);
        repo.makeCallout();
        expect(pm.lastVM).toEqual(true);
    });
    it("Updates when a callout is removed", () => {
        const { pm, repo } = makeTestRig();
        repo.makeCallout("calloutID");
        expect(pm.lastVM).toEqual(true);
        repo.deleteCallout("calloutID");
        expect(pm.lastVM).toEqual(false);
    });
    it("Compares the VMs", () => {
        const { pm } = makeTestRig();
        expect(pm.vmsAreEqual(true, true)).toEqual(true);
        expect(pm.vmsAreEqual(false, false)).toEqual(true);
        expect(pm.vmsAreEqual(false, true)).toEqual(false);
        expect(pm.vmsAreEqual(true, false)).toEqual(false);
    });
    it("Gets by ID", () => {
        const { appObjects, pm } = makeTestRig();
        expect(ModelHasCalloutsPM_1.ModelHasCalloutsPM.get("appObj", appObjects)).toEqual(pm);
    });
});
//# sourceMappingURL=ModelHasCalloutsPM.test.js.map