import { makeAppObjectRepo } from "@vived/core";
import { makeStateMachineEntity } from "../../StateMachine/Entities";
import { makeChannelModelRepo } from "../Entities";
import { makeSerializeActiveModel, } from "./SerializeActiveModel";
import { makeLoadChannelModelUCMock, makeSelectChannelModelUCMock, } from "../Mocks";
function makeTestRig() {
    const appObjects = makeAppObjectRepo();
    const repo = makeChannelModelRepo(appObjects.getOrCreate("Repo"));
    const stateMachine = makeStateMachineEntity(appObjects.getOrCreate("StateMachine"));
    const registerSpy = jest.spyOn(stateMachine, "registerSerializedSystem");
    const serializer = makeSerializeActiveModel(appObjects.getOrCreate("Animation"));
    const mockLoad = makeLoadChannelModelUCMock(appObjects);
    const mockSelect = 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