1import { describe, expect, it } from "vite-plus/test";
2
3import { parseDesktopSnapShotShortcut, snapShotShortcutKeyLabels } from "./snapShotShortcut";
4
5describe("desktop-approved window capture shortcut labels", () => {
6 it.each([
7 ["Press <Shift><Control>2", ["Ctrl", "⇧", "2"]],
8 ["Ctrl+Shift+8", ["Ctrl", "⇧", "8"]],
9 ["Meta+F12", ["Super", "F12"]],
10 ["<Primary><Alt>Return", ["Ctrl", "Alt", "Enter"]],
11 ["<Super>Left", ["Super", "Left"]],
12 ["<Control>space", ["Ctrl", "Space"]],
13 ["<Control>plus", ["Ctrl", "+"]],
14 ["Ctrl++", ["Ctrl", "+"]],
15 ])("formats %s using the shared keycap labels", (label, expected) => {
16 const shortcut = parseDesktopSnapShotShortcut(label);
17 expect(shortcut).not.toBeNull();
18 expect(snapShotShortcutKeyLabels(shortcut!, "Linux")).toEqual(expected);
19 });
20
21 it.each([
22 "",
23 "Ctrl+",
24 "Press the shortcut configured in your desktop",
25 "<Unknown>2",
26 "<Control>UnknownKey",
27 ])("does not guess keys from an unrecognized description: %s", (label) => {
28 expect(parseDesktopSnapShotShortcut(label)).toBeNull();
29 });
30});