"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const core_1 = require("@vived/core");
const MockStateMachine_1 = require("../../StateMachine/Mocks/MockStateMachine");
const BaseAppState_1 = require("../Entity/BaseAppState");
const SerializeBaseAppState_1 = require("./SerializeBaseAppState");
function makeTestRig() {
    const appObjects = (0, core_1.makeAppObjectRepo)();
    const app = appObjects.getOrCreate("app");
    (0, MockStateMachine_1.makeMockStateMachine)(appObjects);
    const baseAppState = (0, BaseAppState_1.makeBaseAppState)(app);
    const serializer = new SerializeBaseAppState_1.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