import { makeAppObjectRepo } from "@vived/core";
import { makeKeyboardInput } from "../../KeyboardInput/Entities/KeyboardInput";
import { makeSelection } from "../Entities";
import { KeyboardToClearSelection } from "./KeyboardToClearSelection";
function makeTestRig() {
    const appObjects = makeAppObjectRepo();
    const selection = makeSelection(appObjects.getOrCreate("selection"));
    const element = document.createElement("div");
    const keyboardInput = makeKeyboardInput(appObjects.getOrCreate("Keyboard"));
    keyboardInput.setEventElement(element);
    const controller = new KeyboardToClearSelection(appObjects.getOrCreate("Controller"));
    return { keyboardInput, controller, element, selection };
}
describe("Keyboard controller to clear the selection", () => {
    it("Clears the Selection", () => {
        const { element, selection } = makeTestRig();
        const spy = jest.spyOn(selection, "selectedObjectId", "set");
        const downEvent = new KeyboardEvent("keydown", { code: "Escape" });
        element.dispatchEvent(downEvent);
        expect(spy).toHaveBeenCalledWith(null);
    });
    it("Not clear the Selection", () => {
        const { element, selection } = makeTestRig();
        const spy = jest.spyOn(selection, "selectedObjectId", "set");
        const downEvent = new KeyboardEvent("keydown", { code: "OtherKey" });
        element.dispatchEvent(downEvent);
        expect(spy).not.toHaveBeenCalled();
    });
});
//# sourceMappingURL=KeyboardToClearSelection.test.js.map