Skip to content

Commit d8b9a83

Browse files
committed
Add test calling directly into bin
1 parent 38d382b commit d8b9a83

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import assert from "node:assert/strict";
2+
import { describe, it } from "node:test";
3+
import cp from "node:child_process";
4+
import path from "node:path";
5+
6+
const PACKAGE_ROOT = path.join(__dirname, "../../..");
7+
const BIN_PATH = path.join(PACKAGE_ROOT, "bin/react-native-node-api.mjs");
8+
9+
describe("bin", () => {
10+
describe("help command", () => {
11+
it("should succeed with a mention of usage", () => {
12+
const { status, stdout, stderr } = cp.spawnSync(BIN_PATH, ["help"], {
13+
cwd: PACKAGE_ROOT,
14+
encoding: "utf-8",
15+
// true on Windows to get the right PATH resolution
16+
shell: process.platform === "win32",
17+
});
18+
19+
assert.equal(
20+
status,
21+
0,
22+
`Expected success (got ${status}): ${stdout} ${stderr}`,
23+
);
24+
assert.match(stdout, /Usage: react-native-node-api/);
25+
});
26+
});
27+
28+
describe("link command", () => {
29+
it("should succeed with a mention of Node-API modules", () => {
30+
const { status, stdout, stderr } = cp.spawnSync(
31+
BIN_PATH,
32+
["link", "--android", "--apple"],
33+
{
34+
cwd: PACKAGE_ROOT,
35+
encoding: "utf-8",
36+
// true on Windows to get the right PATH resolution
37+
shell: process.platform === "win32",
38+
},
39+
);
40+
41+
assert.equal(
42+
status,
43+
0,
44+
`Expected success (got ${status}): ${stdout} ${stderr}`,
45+
);
46+
assert.match(stdout, /Auto-linking Node-API modules/);
47+
});
48+
});
49+
});

0 commit comments

Comments
 (0)