"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const core_1 = require("@vived/core");
const KeyboardInput_1 = require("../../KeyboardInput/Entities/KeyboardInput");
const Entities_1 = require("../Entities");
const KeyboardToClearSelection_1 = require("./KeyboardToClearSelection");
function makeTestRig() {
    const appObjects = (0, core_1.makeAppObjectRepo)();
    const selection = (0, Entities_1.makeSelection)(appObjects.getOrCreate("selection"));
    const element = document.createElement("div");
    const keyboardInput = (0, KeyboardInput_1.makeKeyboardInput)(appObjects.getOrCreate("Keyboard"));
    keyboardInput.setEventElement(element);
    const controller = new KeyboardToClearSelection_1.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