mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-11-21 07:32:54 +00:00
Address #2502: bind shortkeys when quick-adding snippets, add package creation via a split + menu, convert quick-add to a right-side drawer, and let code snippets run on all workspace tabs from the context menu.
34 lines
1.1 KiB
TypeScript
34 lines
1.1 KiB
TypeScript
import test from "node:test";
|
|
import assert from "node:assert/strict";
|
|
import { readFileSync } from "node:fs";
|
|
|
|
import { getQuickAddSnippetInitialCommand } from "./QuickAddSnippetDialog.tsx";
|
|
|
|
const source = readFileSync(new URL("./QuickAddSnippetDialog.tsx", import.meta.url), "utf8");
|
|
|
|
test("quick add snippet event can prefill command", () => {
|
|
const event = {
|
|
detail: { command: "ls -la\npwd" },
|
|
} as CustomEvent<{ command?: string }>;
|
|
|
|
assert.equal(getQuickAddSnippetInitialCommand(event), "ls -la\npwd");
|
|
});
|
|
|
|
test("quick add snippet event defaults to an empty command", () => {
|
|
assert.equal(getQuickAddSnippetInitialCommand({} as Event), "");
|
|
assert.equal(
|
|
getQuickAddSnippetInitialCommand({
|
|
detail: { command: 123 },
|
|
} as unknown as Event),
|
|
"",
|
|
);
|
|
});
|
|
|
|
test("quick add snippet form binds shortkeys and uses a side panel drawer", () => {
|
|
assert.match(source, /AsidePanel/);
|
|
assert.match(source, /snippets\.field\.shortkey/);
|
|
assert.match(source, /keyEventToString/);
|
|
assert.match(source, /shortkey: shortkey \|\| undefined/);
|
|
assert.match(source, /if \(e\.defaultPrevented\) return/);
|
|
});
|