import { makeAppObjectRepo } from "@vived/core";
import { makeBaseAppState } from "../../BaseApp/Entity/BaseAppState";
import { makeKeyboardInput } from "../../KeyboardInput/Entities/KeyboardInput";
import { makeInspectorTabEntity } from "../Entities";
import { KeyboardToSetTab } from "./KeyboardToSetTab";
function makeTestRig() {
    const appObjects = makeAppObjectRepo();
    const baseApp = makeBaseAppState(appObjects.getOrCreate("BaseApp"));
    baseApp.isAuthoring = true;
    const tabEntity = makeInspectorTabEntity(appObjects.getOrCreate("App"));
    tabEntity.setInspectorTabs(["Properties", "Layers", "Challenge"]);
    const element = document.createElement("div");
    const keyboardInput = makeKeyboardInput(appObjects.getOrCreate("Keyboard"));
    keyboardInput.setEventElement(element);
    const controller = new KeyboardToSetTab(appObjects.getOrCreate("Controller"));
    return { controller, element, tabEntity, baseApp };
}
describe("Keyboard controller to set the tab", () => {
    it("Sets Property Tab when Digit1 key was pressed", () => {
        const { element, tabEntity } = makeTestRig();
        tabEntity.activeTab = "Challenge";
        const downEvent = new KeyboardEvent("keydown", { code: "Digit1" });
        element.dispatchEvent(downEvent);
        expect(tabEntity.activeTab).toEqual("Properties");
    });
    it("Sets Hierarchy Tab when Digit2 key was pressed", () => {
        const { element, tabEntity } = makeTestRig();
        tabEntity.activeTab = "Properties";
        const downEvent = new KeyboardEvent("keydown", { code: "Digit2" });
        element.dispatchEvent(downEvent);
        expect(tabEntity.activeTab).toEqual("Layers");
    });
    it("Sets Challenge Tab when Digit3 key was pressed", () => {
        const { element, tabEntity } = makeTestRig();
        tabEntity.activeTab = "Properties";
        const downEvent = new KeyboardEvent("keydown", { code: "Digit3" });
        element.dispatchEvent(downEvent);
        expect(tabEntity.activeTab).toEqual("Challenge");
    });
    it("Does not set if not authoring", () => {
        const { element, tabEntity, baseApp } = makeTestRig();
        expect(tabEntity.activeTab).toEqual("Properties");
        baseApp.isAuthoring = false;
        const downEvent = new KeyboardEvent("keydown", { code: "Digit3" });
        element.dispatchEvent(downEvent);
        expect(tabEntity.activeTab).toEqual("Properties");
    });
    it("Does not set if the index is greater than the tabs", () => {
        const { element, tabEntity } = makeTestRig();
        expect(tabEntity.activeTab).toEqual("Properties");
        const downEvent = new KeyboardEvent("keydown", { code: "Digit4" });
        element.dispatchEvent(downEvent);
        expect(tabEntity.activeTab).toEqual("Properties");
    });
});
//# sourceMappingURL=KeyboardToSetTab.test.js.map