mirror of
https://seed.radicle.dev/rad:z4D5UCArafTzTQpDZNQRuqswh3ury.git
synced 2026-10-24 14:00:36 +08:00
18 lines
436 B
TypeScript
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);
|
|
});
|