21
codex-cli/src/lib/format-command.test.ts
Normal file
21
codex-cli/src/lib/format-command.test.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { formatCommandForDisplay } from "./format-command";
|
||||
import { describe, test, expect } from "vitest";
|
||||
|
||||
describe("formatCommandForDisplay()", () => {
|
||||
test("ensure empty string arg appears in output", () => {
|
||||
expect(formatCommandForDisplay(["echo", ""])).toEqual("echo ''");
|
||||
});
|
||||
|
||||
test("ensure special characters are properly escaped", () => {
|
||||
expect(formatCommandForDisplay(["echo", "$HOME"])).toEqual("echo \\$HOME");
|
||||
});
|
||||
|
||||
test("ensure quotes are properly escaped", () => {
|
||||
expect(formatCommandForDisplay(["echo", "I can't believe this."])).toEqual(
|
||||
'echo "I can\'t believe this."',
|
||||
);
|
||||
expect(
|
||||
formatCommandForDisplay(["echo", 'So I said, "No ma\'am!"']),
|
||||
).toEqual('echo "So I said, \\"No ma\'am\\!\\""');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user