import { makeAppObjectRepo } from "@vived/core";
import { makeMockDispatchStateChange } from "../../Dispatcher/Mocks/MockDispatchStateChange";
import { makeBaseAppState } from "../Entity";
import { makeUpdateContentSizeUC } from "./UpdateContentSizeUC";
function makeTestRig() {
    const appObjects = makeAppObjectRepo();
    const app = appObjects.getOrCreate("app");
    const baseApp = makeBaseAppState(appObjects.getOrCreate("Base App"));
    const doDispatchMock = jest.fn();
    makeMockDispatchStateChange(appObjects).doDispatch = doDispatchMock;
    const updateSizeUC = 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