跳到主要内容

Claude Cage · 面向 Claude 的隔离开发环境,支持桌面工作台、多账号、远程部署与移动端连接。上游 Lee-xeo/Claude-Cage 完整源码镜像,非灵栈原创;主许可 MIT,第三方组件遵循各自许可。来源:https://github.com/Lee-xeo/Claude-Cage 。手动同步,不附带 Release 安装包。

浏览文件

platform.test.mjs

35 行 · 1.8 KB历史下载
1import test from "node:test";
2import assert from "node:assert/strict";
3import { primaryModifier, terminalModifier, shortcut } from "./platform.mjs";
4
5test("Linux defaults to Ctrl and macOS keeps Command", async () => {
6 const descriptor = Object.getOwnPropertyDescriptor(globalThis, "navigator");
7 try {
8 for (const platform of ["Linux x86_64", "Win32", "MacIntel"]) {
9 Object.defineProperty(globalThis, "navigator", { configurable: true, value: { platform } });
10 const api = await import(`./platform.mjs?platform=${encodeURIComponent(platform)}`);
11 const control = platform !== "MacIntel";
12 assert.equal(api.usesControl, control);
13 assert.equal(api.isWindows, platform === "Win32");
14 assert.equal(api.shortcut("⌘O"), control ? "Ctrl+O" : "⌘O");
15 const event = { ctrlKey: true, metaKey: false, altKey: false, shiftKey: false };
16 assert.equal(api.primaryModifier(event), control);
17 assert.equal(api.terminalModifier(event), false);
18 assert.equal(api.terminalModifier({ ...event, shiftKey: true }), control);
19 }
20 } finally {
21 if (descriptor) Object.defineProperty(globalThis, "navigator", descriptor);
22 else delete globalThis.navigator;
23 }
24});
25
26test("Windows shortcuts reserve Ctrl+C for terminal interruption and ignore AltGr", () => {
27 const ctrl = { ctrlKey: true, altKey: false, metaKey: false, shiftKey: false };
28 assert.equal(primaryModifier(ctrl, true), true);
29 assert.equal(terminalModifier(ctrl, true), false);
30 assert.equal(terminalModifier({ ...ctrl, shiftKey: true }, true), true);
31 assert.equal(primaryModifier({ ...ctrl, altKey: true }, true), false);
32 assert.equal(primaryModifier({ ...ctrl, metaKey: true }, false), true);
33 assert.equal(shortcut("⌘⇧↵", true), "Ctrl+Shift+Enter");
34 assert.equal(shortcut("⌘W", false), "⌘W");
35});