import { makeAppObjectRepo } from "@vived/core";
import { makeBaseAppState } from "../../BaseApp/Entity/BaseAppState";
import { makeSelection } from "../Entities/Selection";
import { ClearSelectionUCHook } from "./ClearSelectionUCHook";
function makeTestRig() {
    const appObjects = makeAppObjectRepo();
    const baseApp = makeBaseAppState(appObjects.getOrCreate("BaseApp"));
    const selection = makeSelection(appObjects.getOrCreate("Selection"));
    baseApp.isAuthoring = false;
    new ClearSelectionUCHook(appObjects.getOrCreate("UC"));
    return { appObjects, baseApp, selection };
}
describe("Clear Selection UC Hook", () => {
    it("Clear the pressed object when the is authoring flag changes", () => {
        const { baseApp, selection } = makeTestRig();
        const spy = jest.spyOn(selection, "pressedObjectId", "set");
        baseApp.isAuthoring = true;
        expect(spy).toHaveBeenCalledWith(null);
        spy.mockClear();
        baseApp.isAuthoring = false;
        expect(spy).toHaveBeenCalledWith(null);
        spy.mockClear();
        baseApp.notifyOnChange();
        expect(spy).not.toHaveBeenCalled();
    });
    it("Clear the hovered object when the is authoring flag changes", () => {
        const { baseApp, selection } = makeTestRig();
        const spy = jest.spyOn(selection, "hoveredObjectId", "set");
        baseApp.isAuthoring = true;
        expect(spy).toHaveBeenCalledWith(null);
        spy.mockClear();
        baseApp.isAuthoring = false;
        expect(spy).toHaveBeenCalledWith(null);
        spy.mockClear();
        baseApp.notifyOnChange();
        expect(spy).not.toHaveBeenCalled();
    });
    it("Clear the selected object when the is authoring flag changes", () => {
        const { baseApp, selection } = makeTestRig();
        const spy = jest.spyOn(selection, "selectedObjectId", "set");
        baseApp.isAuthoring = true;
        expect(spy).toHaveBeenCalledWith(null);
        spy.mockClear();
        baseApp.isAuthoring = false;
        expect(spy).toHaveBeenCalledWith(null);
        spy.mockClear();
        baseApp.notifyOnChange();
        expect(spy).not.toHaveBeenCalled();
    });
});
//# sourceMappingURL=ClearSelectionUCHook.test.js.map