forked from JSONPath-Plus/JSONPath
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.cli.js
More file actions
25 lines (22 loc) · 812 Bytes
/
test.cli.js
File metadata and controls
25 lines (22 loc) · 812 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
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(out.stderr).to.include(`usage: ${binPath} <file> <path>\n\n`);
});
});