"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const core_1 = require("@vived/core");
const Entities_1 = require("../../StateMachine/Entities");
const Entities_2 = require("../Entities");
const SerializeActiveModel_1 = require("./SerializeActiveModel");
const Mocks_1 = require("../Mocks");
function makeTestRig() {
    const appObjects = (0, core_1.makeAppObjectRepo)();
    const repo = (0, Entities_2.makeChannelModelRepo)(appObjects.getOrCreate("Repo"));
    const stateMachine = (0, Entities_1.makeStateMachineEntity)(appObjects.getOrCreate("StateMachine"));
    const registerSpy = jest.spyOn(stateMachine, "registerSerializedSystem");
    const serializer = (0, SerializeActiveModel_1.makeSerializeActiveModel)(appObjects.getOrCreate("Animation"));
    const mockLoad = (0, Mocks_1.makeLoadChannelModelUCMock)(appObjects);
    const mockSelect = (0, Mocks_1.makeSelectChannelModelUCMock)(appObjects);
    return { appObjects, repo, serializer, registerSpy, mockLoad, mockSelect };
}
describe("Serialize Animation State", () => {
    it("Registers with the state machine", () => {
        const { registerSpy, serializer } = makeTestRig();
        expect(registerSpy).toHaveBeenCalledWith(serializer);
    });
    it("Forms the state", () => {
        const { serializer, repo } = makeTestRig();
        repo.activeModel = "a model";
        const state = serializer.getSystemState();
        expect(state.modelID).toEqual("a model");
    });
    it("Applies the state", () => {
        const { serializer, repo, mockLoad } = makeTestRig();
        const state = {
            modelID: "a model",
        };
        serializer.applySystemState(state, 1, 1);
        expect(repo.activeModel).toEqual("a model");
        expect(mockLoad.loadChannelModel).toHaveBeenCalledWith("a model");
    });
    it("Set the default state", () => {
        const { serializer, repo, mockSelect } = makeTestRig();
        repo.activeModel = "a repo";
        serializer.applyDefaultState(1);
        expect(repo.activeModel).toEqual("");
        expect(mockSelect.selectChannelModel).toHaveBeenCalled();
    });
});
//# sourceMappingURL=SerializeActiveModel.test.js.map