~james/core

core/web/src/lib/components/shell/topbarSearch.test.ts -rw-r--r-- 782 bytes
452f17b7 — james chore(import): snapshot james.dad.town/core at f70c71c7696a 15 hours ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import { describe, expect, it } from "vitest";
import { moveActive, shortcutLabel } from "#lib/components/shell/topbarSearch.ts";

describe("moveActive", () => {
	it("steps through the results without wrapping", () => {
		expect(moveActive(-1, 1, 3)).toBe(0);
		expect(moveActive(1, 1, 3)).toBe(2);
		expect(moveActive(2, 1, 3)).toBe(2);
	});

	it("returns to the input above the first result", () => {
		expect(moveActive(0, -1, 3)).toBe(-1);
		expect(moveActive(-1, -1, 3)).toBe(-1);
	});

	it("stays on the input when there are no results", () => {
		expect(moveActive(-1, 1, 0)).toBe(-1);
	});
});

describe("shortcutLabel", () => {
	it("names the platform's modifier", () => {
		expect(shortcutLabel(true)).toBe("⌘K");
		expect(shortcutLabel(false)).toBe("Ctrl+K");
	});
});