Skip to content

Commit 729f266

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

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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+
});
16+
17+
assert.equal(
18+
status,
19+
0,
20+
`Expected success (got ${status}): ${stdout} ${stderr}`,
21+
);
22+
assert.match(stdout, /Usage: react-native-node-api/);
23+
});
24+
});
25+
26+
describe("link command", () => {
27+
it("should succeed with a mention of Node-API modules", () => {
28+
const { status, stdout, stderr } = cp.spawnSync(
29+
BIN_PATH,
30+
["link", "--android", "--apple"],
31+
{
32+
cwd: PACKAGE_ROOT,
33+
encoding: "utf-8",
34+
},
35+
);
36+
37+
assert.equal(
38+
status,
39+
0,
40+
`Expected success (got ${status}): ${stdout} ${stderr}`,
41+
);
42+
assert.match(stdout, /Auto-linking Node-API modules/);
43+
});
44+
});
45+
});

0 commit comments

Comments
 (0)