-
-
Notifications
You must be signed in to change notification settings - Fork 974
Expand file tree
/
Copy pathstreamdown.test.ts
More file actions
21 lines (17 loc) · 866 Bytes
/
streamdown.test.ts
File metadata and controls
21 lines (17 loc) · 866 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import { describe, expect, it } from "vitest";
import { canSaveCommand } from "./streamdown";
describe("canSaveCommand", () => {
it("accepts explicit shell code blocks", () => {
expect(canSaveCommand("bash", "npm run build")).toBe(true);
expect(canSaveCommand("pwsh", "Get-ChildItem")).toBe(true);
});
it("accepts shell-looking unlabeled blocks", () => {
expect(canSaveCommand("text", "$ git status\n$ npm test")).toBe(true);
expect(canSaveCommand("text", "docker compose up")).toBe(true);
});
it("rejects empty or obviously non-command blocks", () => {
expect(canSaveCommand("text", "")).toBe(false);
expect(canSaveCommand("javascript", "const x = 1;\nconsole.log(x);")).toBe(false);
expect(canSaveCommand("text", "This is explanatory prose, not a command.")).toBe(false);
});
});