/* Copyright 2026 Lotus Guild SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial Please see LICENSE in the repository root for full details. */ import { describe, expect, it } from "vitest"; import { isEditableTarget, isInteractiveTarget, parseHotkeyCodes, } from "./lotusHotkeys"; describe("parseHotkeyCodes", () => { it("keeps KeyboardEvent.code-like strings", () => { expect(parseHotkeyCodes({ codes: ["Space", "KeyM", "F13"] })).toEqual([ "Space", "KeyM", "F13", ]); }); it("drops junk and caps the list", () => { expect(parseHotkeyCodes({ codes: ["Space", 3, "", "a b", ""] })).toEqual( ["Space"], ); expect(parseHotkeyCodes({ codes: Array(20).fill("KeyA") })).toHaveLength(8); expect(parseHotkeyCodes({})).toEqual([]); expect(parseHotkeyCodes(null)).toEqual([]); }); }); describe("target checks", () => { it("treats inputs and contenteditable as editable", () => { document.body.innerHTML = '
x
'; expect(isEditableTarget(document.getElementById("i"))).toBe(true); expect(isEditableTarget(document.getElementById("s"))).toBe(true); expect(isEditableTarget(document.getElementById("d"))).toBe(false); expect(isEditableTarget(null)).toBe(false); }); it("treats buttons, links and button roles as interactive", () => { document.body.innerHTML = '
m

'; expect(isInteractiveTarget(document.getElementById("b"))).toBe(true); expect(isInteractiveTarget(document.getElementById("m"))).toBe(true); expect(isInteractiveTarget(document.getElementById("p"))).toBe(false); }); });