import { makeAppObjectRepo } from "@vived/core";
import { makeFramedScreen } from "../Entities";
import { FramedScreenSizePM, makeFramedScreenSizePM, } from "./FramedScreenSizePM";
function makeTestRig() {
    const appObjects = makeAppObjectRepo();
    const registerSpy = jest.spyOn(appObjects, "registerSingleton");
    const screenAO = appObjects.getOrCreate("screen");
    const screen = makeFramedScreen(screenAO);
    screen.screenWidth = 10;
    screen.screenHeight = 20;
    const pm = makeFramedScreenSizePM(screenAO);
    return { appObjects, pm, screen, registerSpy };
}
describe("Screen Size Presentation Manager", () => {
    it("Initializes the VM", () => {
        const { pm } = makeTestRig();
        expect(pm.lastVM?.width).toEqual(10);
        expect(pm.lastVM?.height).toEqual(20);
    });
    it("Updates the view when the screen changes", () => {
        const { screen, pm } = makeTestRig();
        screen.screenWidth = 11;
        screen.screenHeight = 22;
        expect(pm.lastVM?.width).toEqual(11);
        expect(pm.lastVM?.height).toEqual(22);
    });
    it("Checks for equal VMs", () => {
        const { pm } = makeTestRig();
        const vm1 = {
            height: 1,
            width: 4,
        };
        const vm2 = { ...vm1 };
        expect(pm.vmsAreEqual(vm1, vm2)).toEqual(true);
    });
    it("Checks for a change in the height", () => {
        const { pm } = makeTestRig();
        const vm1 = {
            height: 1,
            width: 4,
        };
        const vm2 = { ...vm1, height: 10 };
        expect(pm.vmsAreEqual(vm1, vm2)).toEqual(false);
    });
    it("Checks for a change in the width", () => {
        const { pm } = makeTestRig();
        const vm1 = {
            height: 1,
            width: 4,
        };
        const vm2 = { ...vm1, width: 10 };
        expect(pm.vmsAreEqual(vm1, vm2)).toEqual(false);
    });
    it("Gets the singleton", () => {
        const { appObjects, pm } = makeTestRig();
        expect(FramedScreenSizePM.get(appObjects)).toEqual(pm);
    });
    it("Registers as the singleton", () => {
        const { registerSpy, pm } = makeTestRig();
        expect(registerSpy).toHaveBeenCalledWith(pm);
    });
});
//# sourceMappingURL=FramedScreenSizePM.test.js.map