"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const core_1 = require("@vived/core");
const core_2 = require("@vived/core");
const FramedScreenContainer_1 = require("./FramedScreenContainer");
function makeTestRig() {
    const appObjects = (0, core_1.makeAppObjectRepo)();
    const appObject = appObjects.getOrCreate("id1");
    const framedContainer = (0, FramedScreenContainer_1.makeFramedScreenContainer)(appObject);
    const observer = jest.fn();
    framedContainer.addChangeObserver(observer);
    return { framedContainer, observer, appObject };
}
describe("Framed Screen Container Entity", () => {
    it("Sets the id to the app object id", () => {
        const { framedContainer, appObject } = makeTestRig();
        expect(framedContainer.id).toEqual(appObject.id);
    });
    it("Updates the the position changes", () => {
        const { framedContainer, observer } = makeTestRig();
        expect(framedContainer.position).toEqual(core_2.Vector2.Zero());
        framedContainer.position = new core_2.Vector2(1, 2);
        expect(framedContainer.position).toEqual(new core_2.Vector2(1, 2));
        expect(observer).toHaveBeenCalled();
    });
    it("Does not update if there is no change to the position", () => {
        const { framedContainer, observer } = makeTestRig();
        framedContainer.position = new core_2.Vector2(1, 2);
        observer.mockClear();
        framedContainer.position = new core_2.Vector2(1, 2);
        framedContainer.position = new core_2.Vector2(1, 2);
        framedContainer.position = new core_2.Vector2(1, 2);
        expect(observer).not.toHaveBeenCalled();
    });
    it("Updates the the size changes", () => {
        const { framedContainer, observer } = makeTestRig();
        expect(framedContainer.size).toEqual(core_2.Vector2.Zero());
        framedContainer.size = new core_2.Vector2(1, 2);
        expect(framedContainer.size).toEqual(new core_2.Vector2(1, 2));
        expect(observer).toHaveBeenCalled();
    });
    it("Does not update if there is no change to the size", () => {
        const { framedContainer, observer } = makeTestRig();
        framedContainer.size = new core_2.Vector2(1, 2);
        observer.mockClear();
        framedContainer.size = new core_2.Vector2(1, 2);
        framedContainer.size = new core_2.Vector2(1, 2);
        framedContainer.size = new core_2.Vector2(1, 2);
        expect(observer).not.toHaveBeenCalled();
    });
    it("Updates when the show changes", () => {
        const { framedContainer, observer } = makeTestRig();
        expect(framedContainer.show).toEqual(false);
        framedContainer.show = true;
        expect(framedContainer.show).toEqual(true);
        expect(observer).toHaveBeenCalled();
    });
    it("Does not update if there is no change to show", () => {
        const { framedContainer, observer } = makeTestRig();
        expect(framedContainer.show).toEqual(false);
        observer.mockClear();
        framedContainer.show = false;
        framedContainer.show = false;
        framedContainer.show = false;
        expect(observer).not.toHaveBeenCalled();
    });
    it("Allows an observer to be removed", () => {
        const { framedContainer, observer } = makeTestRig();
        framedContainer.removeChangeObserver(observer);
        framedContainer.size = new core_2.Vector2(1, 2);
        framedContainer.position = new core_2.Vector2(1, 2);
        framedContainer.show = false;
        expect(observer).not.toHaveBeenCalled();
    });
});
//# sourceMappingURL=FramedScreenContainer.test.js.map