"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const core_1 = require("@vived/core");
const UndoRedoEntity_1 = require("../Entities/UndoRedoEntity");
const HasUndoPM_1 = require("./HasUndoPM");
function makeTestRig() {
    const appObjects = (0, core_1.makeAppObjectRepo)();
    const app = appObjects.getOrCreate("app");
    const undoRedoEntity = (0, UndoRedoEntity_1.makeUndoRedoEntity)(app);
    const pm = (0, HasUndoPM_1.makeHasUndoPM)(app);
    const mockHasUndo = jest.spyOn(undoRedoEntity, "hasUndo", "get");
    mockHasUndo.mockReturnValue(true);
    return { undoRedoEntity, pm, appObjects, mockHasUndo };
}
describe("Has Redo Presentation Manager", () => {
    it("Updates the view when the the flag changes", () => {
        const { mockHasUndo, pm, undoRedoEntity } = makeTestRig();
        const view = jest.fn();
        pm.addView(view);
        mockHasUndo.mockReturnValue(false);
        undoRedoEntity.notifyOnChange();
        expect(view).toHaveBeenCalledWith(false);
        mockHasUndo.mockReturnValue(true);
        undoRedoEntity.notifyOnChange();
        expect(view).toHaveBeenCalledWith(true);
    });
    it("Checks for VMs to be equal", () => {
        const { pm } = makeTestRig();
        expect(pm.vmsAreEqual(false, true)).toEqual(false);
        expect(pm.vmsAreEqual(true, false)).toEqual(false);
        expect(pm.vmsAreEqual(true, true)).toEqual(true);
        expect(pm.vmsAreEqual(false, false)).toEqual(true);
    });
    it("Warns if it is added to something that does not have a App State Entity", () => {
        const { appObjects } = makeTestRig();
        appObjects.submitWarning = jest.fn();
        const ao = appObjects.getOrCreate("anotherOne");
        (0, HasUndoPM_1.makeHasUndoPM)(ao);
        expect(appObjects.submitWarning).toHaveBeenCalled();
    });
    it("Gets the PM", () => {
        const { pm, appObjects } = makeTestRig();
        expect(HasUndoPM_1.HasUndoPM.get(appObjects)).toEqual(pm);
    });
});
//# sourceMappingURL=HasUndoPM.test.js.map