File
Blob: tests/client/components/editor/controllers/menu/navigation.test.ts
| 1 | import { describe, expect, it } from "vitest"; |
| 2 | import { getInitialMenuIndex, moveMenuIndex } from "@/client/components/editor/controllers/menu/navigation"; |
| 3 | |
| 4 | describe("menu navigation helpers", () => { |
| 5 | it("clamps the initial selection to the available range", () => { |
| 6 | expect(getInitialMenuIndex(0)).toBe(-1); |
| 7 | expect(getInitialMenuIndex(3)).toBe(0); |
| 8 | expect(getInitialMenuIndex(3, 2)).toBe(2); |
| 9 | expect(getInitialMenuIndex(3, 99)).toBe(2); |
| 10 | }); |
| 11 | |
| 12 | it("wraps forward through the available items", () => { |
| 13 | expect(moveMenuIndex(-1, 3, 1)).toBe(0); |
| 14 | expect(moveMenuIndex(0, 3, 1)).toBe(1); |
| 15 | expect(moveMenuIndex(2, 3, 1)).toBe(0); |
| 16 | }); |
| 17 | |
| 18 | it("wraps backward through the available items", () => { |
| 19 | expect(moveMenuIndex(-1, 3, -1)).toBe(2); |
| 20 | expect(moveMenuIndex(2, 3, -1)).toBe(1); |
| 21 | expect(moveMenuIndex(0, 3, -1)).toBe(2); |
| 22 | }); |
| 23 | }); |