Skip to content

Commit e300b1b

Browse files
committed
Add tests for stdin quote strip
1 parent 306e50f commit e300b1b

File tree

1 file changed

+33
-1
lines changed

1 file changed

+33
-1
lines changed

test/test.js

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,5 +103,37 @@ test('Works with stdin', async (t) => {
103103

104104
await waitForStreamClose(create);
105105

106-
assert.ok(fs.existsSync(path));
106+
assert.deepEqual(fs.readFileSync(path, "utf8"), SAMPLE_CONTENT);
107+
});
108+
109+
test('Trim single quotes on stdin', async (t) => {
110+
t.after(() => {
111+
rimrafSync("./test/stubs-stdin-single-quote/");
112+
});
113+
114+
let echo = spawn('echo', [`'${SAMPLE_CONTENT}'`]);
115+
let path = 'test/stubs-stdin-single-quote/index.md';
116+
let create = spawn("node", ['.', path]);
117+
118+
echo.stdout.pipe(create.stdin);
119+
120+
await waitForStreamClose(create);
121+
122+
assert.deepEqual(fs.readFileSync(path, "utf8"), SAMPLE_CONTENT);
123+
});
124+
125+
test('Trim double quotes on stdin', async (t) => {
126+
t.after(() => {
127+
rimrafSync("./test/stubs-stdin-double-quote/");
128+
});
129+
130+
let echo = spawn('echo', [`"${SAMPLE_CONTENT}"`]);
131+
let path = 'test/stubs-stdin-double-quote/index.md';
132+
let create = spawn("node", ['.', path]);
133+
134+
echo.stdout.pipe(create.stdin);
135+
136+
await waitForStreamClose(create);
137+
138+
assert.deepEqual(fs.readFileSync(path, "utf8"), SAMPLE_CONTENT);
107139
});

0 commit comments

Comments
 (0)