"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const core_1 = require("@vived/core");
const core_2 = require("@vived/core");
const Entities_1 = require("../Entities");
const FramedContainerPM_1 = require("./FramedContainerPM");
function makeTestRig() {
    const appObjects = (0, core_1.makeAppObjectRepo)();
    const containerAO = appObjects.getOrCreate("container1");
    const container = (0, Entities_1.makeFramedScreenContainer)(containerAO);
    container.position = new core_2.Vector2(1, 2);
    container.size = new core_2.Vector2(3, 4);
    const pm = (0, FramedContainerPM_1.makeFramedContainerPM)(containerAO);
    return { appObjects, pm, container };
}
describe("Framed Container Presentation Manager", () => {
    it("Gets the PM", () => {
        const { pm, appObjects } = makeTestRig();
        expect(FramedContainerPM_1.FramedContainerPM.get("container1", appObjects)).toEqual(pm);
    });
    it("Initializes the VM", () => {
        const { pm } = makeTestRig();
        expect(pm.lastVM?.left).toEqual(1);
        expect(pm.lastVM?.top).toEqual(2);
        expect(pm.lastVM?.width).toEqual(3);
        expect(pm.lastVM?.height).toEqual(4);
    });
    it("Updates the view when the container changes", () => {
        const { container, pm } = makeTestRig();
        container.position = new core_2.Vector2(11, 22);
        expect(pm.lastVM?.left).toEqual(11);
        expect(pm.lastVM?.top).toEqual(22);
    });
    it("Checks for equal VMs", () => {
        const { pm } = makeTestRig();
        const vm1 = {
            height: 1,
            left: 2,
            top: 3,
            width: 4,
            show: true,
        };
        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,
            left: 2,
            top: 3,
            width: 4,
            show: true,
        };
        const vm2 = { ...vm1, height: 10 };
        expect(pm.vmsAreEqual(vm1, vm2)).toEqual(false);
    });
    it("Checks for a change in the left", () => {
        const { pm } = makeTestRig();
        const vm1 = {
            height: 1,
            left: 2,
            top: 3,
            width: 4,
            show: true,
        };
        const vm2 = { ...vm1, left: 10 };
        expect(pm.vmsAreEqual(vm1, vm2)).toEqual(false);
    });
    it("Checks for a change in the top", () => {
        const { pm } = makeTestRig();
        const vm1 = {
            height: 1,
            left: 2,
            top: 3,
            width: 4,
            show: true,
        };
        const vm2 = { ...vm1, top: 10 };
        expect(pm.vmsAreEqual(vm1, vm2)).toEqual(false);
    });
    it("Checks for a change in the width", () => {
        const { pm } = makeTestRig();
        const vm1 = {
            height: 1,
            left: 2,
            top: 3,
            width: 4,
            show: true,
        };
        const vm2 = { ...vm1, width: 10 };
        expect(pm.vmsAreEqual(vm1, vm2)).toEqual(false);
    });
    it("Checks for a change in the show", () => {
        const { pm } = makeTestRig();
        const vm1 = {
            height: 1,
            left: 2,
            top: 3,
            width: 4,
            show: true,
        };
        const vm2 = { ...vm1, show: false };
        expect(pm.vmsAreEqual(vm1, vm2)).toEqual(false);
    });
});
//# sourceMappingURL=FramedContainerPM.test.js.map