-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathbin.test.ts
More file actions
57 lines (52 loc) · 1.5 KB
/
bin.test.ts
File metadata and controls
57 lines (52 loc) · 1.5 KB
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import assert from "node:assert/strict";
import { describe, it } from "node:test";
import cp from "node:child_process";
import path from "node:path";
const PACKAGE_ROOT = path.join(__dirname, "../../..");
const BIN_PATH = path.join(PACKAGE_ROOT, "bin/react-native-node-api.mjs");
describe("bin", () => {
describe("help command", () => {
it("should succeed with a mention of usage", () => {
const { status, stdout, stderr } = cp.spawnSync(
process.execPath,
[BIN_PATH, "help"],
{
cwd: PACKAGE_ROOT,
encoding: "utf8",
},
);
assert.equal(
status,
0,
`Expected success (got ${status}): ${stdout} ${stderr}`,
);
assert.match(
stdout,
/Usage: react-native-node-api/,
`Failed to find expected output (stdout: ${stdout} stderr: ${stderr})`,
);
});
});
describe("link command", () => {
it("should succeed with a mention of Node-API modules", () => {
const { status, stdout, stderr } = cp.spawnSync(
process.execPath,
[BIN_PATH, "link", "--android", "--apple"],
{
cwd: PACKAGE_ROOT,
encoding: "utf8",
},
);
assert.equal(
status,
0,
`Expected success (got ${status}): ${stdout} ${stderr}`,
);
assert.match(
stdout + stderr,
/Auto-linking Node-API modules/,
`Failed to find expected output (stdout: ${stdout} stderr: ${stderr})`,
);
});
});
});