"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const core_1 = require("@vived/core");
const BaseAppState_1 = require("../../BaseApp/Entity/BaseAppState");
const KeyboardInput_1 = require("../../KeyboardInput/Entities/KeyboardInput");
const Entities_1 = require("../Entities");
const KeyboardToSetTab_1 = require("./KeyboardToSetTab");
function makeTestRig() {
    const appObjects = (0, core_1.makeAppObjectRepo)();
    const baseApp = (0, BaseAppState_1.makeBaseAppState)(appObjects.getOrCreate("BaseApp"));
    baseApp.isAuthoring = true;
    const tabEntity = (0, Entities_1.makeInspectorTabEntity)(appObjects.getOrCreate("App"));
    tabEntity.setInspectorTabs(["Properties", "Layers", "Challenge"]);
    const element = document.createElement("div");
    const keyboardInput = (0, KeyboardInput_1.makeKeyboardInput)(appObjects.getOrCreate("Keyboard"));
    keyboardInput.setEventElement(element);
    const controller = new KeyboardToSetTab_1.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