Files
Netcatty/components/terminal/runtime/terminalInterruptShortcut.test.ts
T
陈大猫 7db654d751 [codex] complete Kitty keyboard protocol (#2389)
* feat: complete Kitty keyboard protocol

* test: document Kitty text release behavior
2026-07-22 11:56:53 +08:00

43 lines
1.5 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import assert from "node:assert/strict";
import test from "node:test";
import { shouldUseUrgentTerminalInterrupt } from "./terminalInterruptShortcut";
function key(overrides: Partial<KeyboardEvent> = {}): KeyboardEvent {
return {
key: "c",
code: "KeyC",
ctrlKey: true,
metaKey: false,
altKey: false,
shiftKey: false,
...overrides,
} as KeyboardEvent;
}
test("urgent interrupt handles plain Ctrl+C with no selection", () => {
assert.equal(shouldUseUrgentTerminalInterrupt(key(), { hasSelection: false }), true);
});
test("urgent interrupt follows the physical C key on non-Latin layouts", () => {
assert.equal(shouldUseUrgentTerminalInterrupt(key({ key: "с" }), { hasSelection: false }), true);
});
test("urgent interrupt prefers an active ASCII layout character over its physical key", () => {
assert.equal(
shouldUseUrgentTerminalInterrupt(key({ key: "c", code: "KeyJ" }), { hasSelection: false }),
true,
);
assert.equal(
shouldUseUrgentTerminalInterrupt(key({ key: "j", code: "KeyC" }), { hasSelection: false }),
false,
);
});
test("urgent interrupt leaves copy shortcuts and modified chords alone", () => {
assert.equal(shouldUseUrgentTerminalInterrupt(key(), { hasSelection: true }), false);
assert.equal(shouldUseUrgentTerminalInterrupt(key({ shiftKey: true }), { hasSelection: false }), false);
assert.equal(shouldUseUrgentTerminalInterrupt(key({ metaKey: true }), { hasSelection: false }), false);
assert.equal(shouldUseUrgentTerminalInterrupt(key({ altKey: true }), { hasSelection: false }), false);
});