"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const core_1 = require("@vived/core");
const MockDispatchStateChange_1 = require("../../Dispatcher/Mocks/MockDispatchStateChange");
const Entity_1 = require("../Entity");
const UpdateContentSizeUC_1 = require("./UpdateContentSizeUC");
function makeTestRig() {
    const appObjects = (0, core_1.makeAppObjectRepo)();
    const app = appObjects.getOrCreate("app");
    const baseApp = (0, Entity_1.makeBaseAppState)(appObjects.getOrCreate("Base App"));
    const doDispatchMock = jest.fn();
    (0, MockDispatchStateChange_1.makeMockDispatchStateChange)(appObjects).doDispatch = doDispatchMock;
    const updateSizeUC = (0, UpdateContentSizeUC_1.makeUpdateContentSizeUC)(app);
    const updateSize = updateSizeUC.updateContentSize;
    return { baseApp, updateSize, doDispatchMock };
}
describe("Update Content Size", () => {
    it("Sets the value in the entity", () => {
        const { baseApp, updateSize } = makeTestRig();
        baseApp.slideInfoContentHeight = 10;
        updateSize(15);
        expect(baseApp.slideInfoContentHeight).toEqual(15);
    });
    it("Dispatches a state change", () => {
        const { baseApp, updateSize, doDispatchMock } = makeTestRig();
        baseApp.slideInfoContentHeight = 10;
        updateSize(15);
        expect(doDispatchMock).toHaveBeenCalled();
    });
    it("Does not dispatches if there is no change.", () => {
        const { baseApp, updateSize, doDispatchMock } = makeTestRig();
        doDispatchMock.mockClear(); // Clear previous mock calls
        baseApp.slideInfoContentHeight = 10;
        updateSize(10);
        expect(doDispatchMock).not.toHaveBeenCalled();
    });
    it("Rounds the size up", () => {
        const { baseApp, updateSize } = makeTestRig();
        updateSize(15.1);
        expect(baseApp.slideInfoContentHeight).toEqual(16);
    });
});
//# sourceMappingURL=UpdateContentSizeUC.test.js.map