Skip to content

Commit 8d9c853

Browse files
committed
Add sanity test of napi binding
1 parent 4f2ecae commit 8d9c853

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,6 @@ node_modules
2828

2929
/napi/*
3030
!/napi/src
31+
!/napi/test
3132
!/napi/*.rs
3233
!/napi/Cargo.toml

napi/test/sanity.spec.mjs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// @ts-check
2+
import * as assert from "node:assert";
3+
import { resolve, join } from "node:path";
4+
import { fileURLToPath } from "node:url";
5+
import { getAffected } from "../index.js";
6+
7+
const fixturesPath = resolve(
8+
fileURLToPath(import.meta.url),
9+
"../../../fixtures/nested"
10+
);
11+
12+
const testFiles = [
13+
join(fixturesPath, "module.spec.js"),
14+
join(fixturesPath, "sub-module.spec.js"),
15+
];
16+
const changedFiles = [join(fixturesPath, "another-module.js")];
17+
const resolverOptions = {
18+
extensions: [".js", ".jsx", ".ts", ".tsx"],
19+
moduleDirectories: ["node_modules"],
20+
rootDir: process.cwd(),
21+
};
22+
23+
const affected = getAffected(testFiles, changedFiles, resolverOptions);
24+
25+
assert.deepEqual(affected.errors, []);
26+
assert.deepEqual(affected.files.sort(), testFiles.sort());

0 commit comments

Comments
 (0)