import { makeAppObjectRepo } from "@vived/core";
import { makeMockStateMachine } from "../../StateMachine/Mocks/MockStateMachine";
import { makeBaseAppState } from "../Entity/BaseAppState";
import { SerializeBaseAppState, } from "./SerializeBaseAppState";
function makeTestRig() {
    const appObjects = makeAppObjectRepo();
    const app = appObjects.getOrCreate("app");
    makeMockStateMachine(appObjects);
    const baseAppState = makeBaseAppState(app);
    const serializer = new SerializeBaseAppState(app);
    return { serializer, baseAppState };
}
describe("Serialize Base App State UC", () => {
    it("Applies the state correctly", () => {
        const { serializer, baseAppState } = makeTestRig();
        const state = {
            slideText: "Hello World",
            slideInfoContentHeight: 100,
        };
        baseAppState.slideText = "Some Text";
        baseAppState.slideInfoContentHeight = 500;
        serializer.applySystemState(state, 1);
        expect(baseAppState.slideText).toEqual("Hello World");
        expect(baseAppState.slideInfoContentHeight).toEqual(100);
    });
    it("Sets the default state as expected", () => {
        const { serializer, baseAppState } = makeTestRig();
        baseAppState.slideText = "Some Text";
        baseAppState.slideInfoContentHeight = 500;
        serializer.applyDefaultState();
        expect(baseAppState.slideText).toEqual("");
        expect(baseAppState.slideInfoContentHeight).toEqual(0);
    });
    it("Applies the default state if an unsupported version is passed in", () => {
        const { serializer } = makeTestRig();
        serializer.applyDefaultState = jest.fn();
        serializer.applySystemState({ foo: "bar" }, -1);
        expect(serializer.applyDefaultState).toHaveBeenCalled();
    });
    it("Serializes the state as expected", () => {
        const { serializer, baseAppState } = makeTestRig();
        baseAppState.slideText = "Some Text";
        baseAppState.slideInfoContentHeight = 500;
        const state = serializer.getSystemState();
        expect(state.slideText).toEqual("Some Text");
        expect(state.slideInfoContentHeight).toEqual(500);
    });
    it("Applies the default state if the state is bungled", () => {
        const { serializer } = makeTestRig();
        serializer.applyDefaultState = jest.fn();
        serializer.applySystemState({ foo: "bar" }, 1);
        expect(serializer.applyDefaultState).toHaveBeenCalled();
    });
});
//# sourceMappingURL=SerializeBaseAppState.test.js.map