-
-
Notifications
You must be signed in to change notification settings - Fork 205
Expand file tree
/
Copy pathtest.cli.js
More file actions
28 lines (25 loc) · 880 Bytes
/
Copy pathtest.cli.js
File metadata and controls
28 lines (25 loc) · 880 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import {promisify} from "util";
import {exec as _exec} from "child_process";
import path from "path";
const exec = promisify(_exec);
describe("JSONPath - cli", () => {
it("with filePath and jsonPath", async () => {
const out = await exec("bin/jsonpath-cli.js package.json name");
expect(out.stdout).to.equal("[ 'jsonpath-plus' ]\n");
});
it("invalid arguments", async () => {
const binPath = path.resolve("bin/jsonpath-cli.js");
let out;
try {
out = await exec("bin/jsonpath-cli.js wrong-file.json");
} catch (err) {
out = err;
}
expect(out).to.have.property("code", 1);
expect(out).to.have.property("stderr");
expect(
/** @type {{stderr: string}} */
(out).stderr
).to.include(`usage: ${binPath} <file> <path>\n\n`);
});
});