Files
radicle-desktop/tests/unit/menuNavigation.test.ts
Rūdolfs Ošiņš f0d4d678aa Focus the last menu item on ArrowUp
With nothing focused yet, ArrowUp landed on the second to last item.
2026-10-01 18:20:25 +02:00

18 lines
436 B
TypeScript

import { expect, test } from "vitest";
import { menuFocusIndex } from "@app/lib/menuNavigation";
test.each([
["ArrowDown", -1, 0],
["ArrowDown", 0, 1],
["ArrowDown", 2, 0],
["ArrowUp", -1, 2],
["ArrowUp", 0, 2],
["ArrowUp", 2, 1],
["Home", 1, 0],
["End", 0, 2],
["Enter", 1, undefined],
])("%j from %j of three focuses %j", (key, current, expected) => {
expect(menuFocusIndex(key, current, 3)).toBe(expected);
});