test: add escaped dollar sign output cases
This commit is contained in:
parent
e829c67e88
commit
341a2fee42
|
|
@ -112,6 +112,21 @@ describe("parse", () => {
|
||||||
expect(result.commands[0]!.expected).toEqual(["$ hello"])
|
expect(result.commands[0]!.expected).toEqual(["$ hello"])
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test("multiple escaped dollar signs", () => {
|
||||||
|
const content = "$ printf '$ a\\n$ b\\n'\n\\$ a\n\\$ b\n"
|
||||||
|
const result = parse("test.shout", content)
|
||||||
|
expect(result.commands).toHaveLength(1)
|
||||||
|
expect(result.commands[0]!.expected).toEqual(["$ a", "$ b"])
|
||||||
|
})
|
||||||
|
|
||||||
|
test("escaped dollar before first command is ignored", () => {
|
||||||
|
const content = "\\$ not a command\n$ echo hi\nhi\n"
|
||||||
|
const result = parse("test.shout", content)
|
||||||
|
// \$ before any command — no current command to attach to, so skipped
|
||||||
|
expect(result.commands).toHaveLength(1)
|
||||||
|
expect(result.commands[0]!.expected).toEqual(["hi"])
|
||||||
|
})
|
||||||
|
|
||||||
test("no directives returns empty array", () => {
|
test("no directives returns empty array", () => {
|
||||||
const result = parse("test.shout", "$ echo hi\nhi\n")
|
const result = parse("test.shout", "$ echo hi\nhi\n")
|
||||||
expect(result.directives).toEqual([])
|
expect(result.directives).toEqual([])
|
||||||
|
|
|
||||||
9
test/dollar-sign-output.shout
Normal file
9
test/dollar-sign-output.shout
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
$ echo '$ hello world'
|
||||||
|
\$ hello world
|
||||||
|
|
||||||
|
$ printf '$ line one\n$ line two\n'
|
||||||
|
\$ line one
|
||||||
|
\$ line two
|
||||||
|
|
||||||
|
$ echo 'no dollar here'
|
||||||
|
no dollar here
|
||||||
Loading…
Reference in New Issue
Block a user