File size: 1,260 Bytes
1187b53 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | import { describe, expect, it } from "vitest";
import { filterToolboxTabs, isEditableElement, shortcutLabel } from "./toolboxNavigation";
describe("toolboxNavigation", () => {
it("filters tabs by title/description/key", () => {
const tabs = [
{ key: "routers", title: "Routers", desc: "Lifecycle and replacements" },
{ key: "masters", title: "Master's AI", desc: "Docs and pricing support" },
{ key: "pots", title: "POTS Q&A", desc: "Provider comparisons" },
];
expect(filterToolboxTabs(tabs, "doc").map((x) => x.key)).toEqual(["masters"]);
expect(filterToolboxTabs(tabs, "router").map((x) => x.key)).toEqual(["routers"]);
expect(filterToolboxTabs(tabs, "").length).toBe(3);
});
it("detects editable elements", () => {
const input = document.createElement("input");
const div = document.createElement("div");
expect(isEditableElement(input)).toBe(true);
expect(isEditableElement(div)).toBe(false);
div.setAttribute("contenteditable", "true");
expect(isEditableElement(div)).toBe(true);
});
it("returns shortcut labels for first nine tabs", () => {
expect(shortcutLabel(0)).toBe("Alt+1");
expect(shortcutLabel(8)).toBe("Alt+9");
expect(shortcutLabel(9)).toBe("");
});
});
|