import { makeAppObjectRepo } from "@vived/core";
import { makeBaseAppState } from "../Entity";
import { SlideNavigationPM, makeSlideNavigationPM, } from "./SlideNavigationPM";
function makeTestRig() {
    const appObjects = makeAppObjectRepo();
    const registerSpy = jest.spyOn(appObjects, "registerSingleton");
    const app = appObjects.getOrCreate("app");
    const baseApp = makeBaseAppState(app);
    const pm = makeSlideNavigationPM(app);
    return { baseApp, pm, appObjects, registerSpy };
}
describe("Has Next Previous State Presentation Manager", () => {
    it("Updates the vm when the the flag changes", () => {
        const { baseApp, pm } = makeTestRig();
        expect(pm.lastVM?.hasNextState).toEqual(false);
        expect(pm.lastVM?.hasPreviousState).toEqual(false);
        baseApp.hasNextState = true;
        baseApp.hasPreviousState = true;
        expect(pm.lastVM?.hasNextState).toEqual(true);
        expect(pm.lastVM?.hasPreviousState).toEqual(true);
    });
    it("Checks for VMs to be equal", () => {
        const { pm } = makeTestRig();
        const vm1 = {
            hasNextState: true,
            hasPreviousState: true,
            hideNavigation: true,
        };
        const vm2 = { ...vm1 };
        expect(pm.vmsAreEqual(vm1, vm2)).toEqual(true);
    });
    it("Checks for a change in has next state", () => {
        const { pm } = makeTestRig();
        const vm1 = {
            hasNextState: true,
            hasPreviousState: true,
            hideNavigation: true,
        };
        const vm2 = { ...vm1, hasNextState: false };
        expect(pm.vmsAreEqual(vm1, vm2)).toEqual(false);
    });
    it("Checks for a change in has previous state", () => {
        const { pm } = makeTestRig();
        const vm1 = {
            hasNextState: true,
            hasPreviousState: true,
            hideNavigation: true,
        };
        const vm2 = { ...vm1, hasPreviousState: false };
        expect(pm.vmsAreEqual(vm1, vm2)).toEqual(false);
    });
    it("Checks for a change in hide nav", () => {
        const { pm } = makeTestRig();
        const vm1 = {
            hasNextState: true,
            hasPreviousState: true,
            hideNavigation: true,
        };
        const vm2 = { ...vm1, hideNavigation: false };
        expect(pm.vmsAreEqual(vm1, vm2)).toEqual(false);
    });
    it("Initializes the VM", () => {
        const { pm } = makeTestRig();
        expect(pm.lastVM).not.toBeUndefined();
    });
    it("Gets the PM", () => {
        const { pm, appObjects } = makeTestRig();
        expect(SlideNavigationPM.get(appObjects)).toEqual(pm);
    });
    it("Registers as the singleton", () => {
        const { pm, registerSpy } = makeTestRig();
        expect(registerSpy).toHaveBeenCalledWith(pm);
    });
});
//# sourceMappingURL=SlideNavigationPM.test.js.map