| 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(""); |
| }); |
| }); |
|
|