"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const core_1 = require("@vived/core");
const UndoRedoEntity_1 = require("../Entities/UndoRedoEntity");
const HasRedoPM_1 = require("./HasRedoPM");
function makeTestRig() {
    const appObjects = (0, core_1.makeAppObjectRepo)();
    const app = appObjects.getOrCreate("app");
    const undoRedoEntity = (0, UndoRedoEntity_1.makeUndoRedoEntity)(app);
    const pm = (0, HasRedoPM_1.makeHasRedoPM)(app);
    const mockHasRedo = jest.spyOn(undoRedoEntity, "hasRedo", "get");
    mockHasRedo.mockReturnValue(true);
    return { undoRedoEntity, pm, appObjects, mockHasRedo };
}
describe("Has Redo Presentation Manager", () => {
    it("Updates the view when the the flag changes", () => {
        const { mockHasRedo, pm, undoRedoEntity } = makeTestRig();
        const view = jest.fn();
        pm.addView(view);
        mockHasRedo.mockReturnValue(false);
        undoRedoEntity.notifyOnChange();
        expect(view).toHaveBeenCalledWith(false);
        mockHasRedo.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, HasRedoPM_1.makeHasRedoPM)(ao);
        expect(appObjects.submitWarning).toHaveBeenCalled();
    });
    it("Gets the PM", () => {
        const { pm, appObjects } = makeTestRig();
        expect(HasRedoPM_1.HasRedoPM.get(appObjects)).toEqual(pm);
    });
});
//# sourceMappingURL=HasRedoPM.test.js.map