Skip to content

Commit a980110

Browse files
committed
Fix tests
1 parent ee8cc64 commit a980110

File tree

2 files changed

+31
-32
lines changed

2 files changed

+31
-32
lines changed

packages/react-native-node-api-modules/src/node/babel-plugin/plugin.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ describe("plugin", () => {
1212
it("transforms require calls, regardless", (context) => {
1313
const tempDirectoryPath = setupTempDirectory(context, {
1414
"package.json": `{ "name": "my-package" }`,
15-
"addon-1.xcframework/addon-1.node":
15+
"addon-1.apple.node/addon-1.node":
1616
"// This is supposed to be a binary file",
17-
"addon-2.xcframework/addon-2.node":
17+
"addon-2.apple.node/addon-2.node":
1818
"// This is supposed to be a binary file",
1919
"addon-1.js": `
2020
const addon = require('./addon-1.node');

packages/react-native-node-api-modules/src/node/path-utils.test.ts

Lines changed: 29 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ import { setupTempDirectory } from "./test-utils.js";
1616
describe("isNodeApiModule", () => {
1717
it("returns true for .node", (context) => {
1818
const tempDirectoryPath = setupTempDirectory(context, {
19-
"addon.xcframework/addon.node":
20-
"// This is supposted to be a binary file",
19+
"addon.apple.node/addon.node": "// This is supposted to be a binary file",
2120
});
2221

2322
assert(isNodeApiModule(path.join(tempDirectoryPath, "addon")));
@@ -63,9 +62,9 @@ describe("isNodeApiModule", () => {
6362
assert.equal(isNodeApiModule(fakePath), false);
6463
});
6564

66-
it("recognize .xcframeworks", (context) => {
65+
it("recognize .apple.node directories", (context) => {
6766
const tempDirectoryPath = setupTempDirectory(context, {
68-
"addon.xcframework/addon.node": "// This is supposed to be a binary file",
67+
"addon.apple.node/addon.node": "// This is supposed to be a binary file",
6968
});
7069
assert.equal(isNodeApiModule(path.join(tempDirectoryPath, "addon")), true);
7170
assert.equal(
@@ -78,7 +77,7 @@ describe("isNodeApiModule", () => {
7877
it("throws when one module unreadable but another readable", (context) => {
7978
const tempDirectoryPath = setupTempDirectory(context, {
8079
"addon.android.node": "",
81-
"addon.xcframework": "",
80+
"addon.apple.node": "",
8281
});
8382
const unreadable = path.join(tempDirectoryPath, "addon.android.node");
8483
// only android module is unreadable
@@ -160,8 +159,8 @@ describe("getLibraryName", () => {
160159
it("works when including relative path", (context) => {
161160
const tempDirectoryPath = setupTempDirectory(context, {
162161
"package.json": `{ "name": "my-package" }`,
163-
"addon.xcframework/addon.node": "// This is supposed to be a binary file",
164-
"sub-directory/addon.xcframework/addon.node":
162+
"addon.apple.node/addon.node": "// This is supposed to be a binary file",
163+
"sub-directory/addon.apple.node/addon.node":
165164
"// This is supposed to be a binary file",
166165
});
167166
assert.equal(
@@ -182,8 +181,8 @@ describe("getLibraryName", () => {
182181
it("works when stripping relative path", (context) => {
183182
const tempDirectoryPath = setupTempDirectory(context, {
184183
"package.json": `{ "name": "my-package" }`,
185-
"addon.xcframework/addon.node": "// This is supposed to be a binary file",
186-
"sub-directory/addon.xcframework/addon.node":
184+
"addon.apple.node/addon.node": "// This is supposed to be a binary file",
185+
"sub-directory/addon.apple.node/addon.node":
187186
"// This is supposed to be a binary file",
188187
});
189188
assert.equal(
@@ -237,45 +236,45 @@ describe("findPackageDependencyPaths", () => {
237236
});
238237

239238
describe("findNodeApiModulePaths", () => {
240-
it("should find xcframework paths", (context) => {
239+
it("should find .apple.node paths", (context) => {
241240
const tempDir = setupTempDirectory(context, {
242-
"root.xcframework/react-native-node-api-module": "",
243-
"sub-directory/lib-a.xcframework/react-native-node-api-module": "",
244-
"sub-directory/lib-b.xcframework/react-native-node-api-module": "",
241+
"root.apple.node/react-native-node-api-module": "",
242+
"sub-directory/lib-a.apple.node/react-native-node-api-module": "",
243+
"sub-directory/lib-b.apple.node/react-native-node-api-module": "",
245244
});
246245
const result = findNodeApiModulePaths({
247246
fromPath: tempDir,
248247
platform: "apple",
249248
});
250249
assert.deepEqual(result.sort(), [
251-
path.join(tempDir, "root.xcframework"),
252-
path.join(tempDir, "sub-directory/lib-a.xcframework"),
253-
path.join(tempDir, "sub-directory/lib-b.xcframework"),
250+
path.join(tempDir, "root.apple.node"),
251+
path.join(tempDir, "sub-directory/lib-a.apple.node"),
252+
path.join(tempDir, "sub-directory/lib-b.apple.node"),
254253
]);
255254
});
256255

257256
it("respects default exclude patterns", (context) => {
258257
const tempDir = setupTempDirectory(context, {
259-
"root.xcframework/react-native-node-api-module": "",
260-
"child-dir/dependency/lib.xcframework/react-native-node-api-module": "",
261-
"child-dir/node_modules/dependency/lib.xcframework/react-native-node-api-module":
258+
"root.apple.node/react-native-node-api-module": "",
259+
"child-dir/dependency/lib.apple.node/react-native-node-api-module": "",
260+
"child-dir/node_modules/dependency/lib.apple.node/react-native-node-api-module":
262261
"",
263262
});
264263
const result = findNodeApiModulePaths({
265264
fromPath: tempDir,
266265
platform: "apple",
267266
});
268267
assert.deepEqual(result.sort(), [
269-
path.join(tempDir, "child-dir/dependency/lib.xcframework"),
270-
path.join(tempDir, "root.xcframework"),
268+
path.join(tempDir, "child-dir/dependency/lib.apple.node"),
269+
path.join(tempDir, "root.apple.node"),
271270
]);
272271
});
273272

274273
it("respects explicit exclude patterns", (context) => {
275274
const tempDir = setupTempDirectory(context, {
276-
"root.xcframework/react-native-node-api-module": "",
277-
"child-dir/dependency/lib.xcframework/react-native-node-api-module": "",
278-
"child-dir/node_modules/dependency/lib.xcframework/react-native-node-api-module":
275+
"root.apple.node/react-native-node-api-module": "",
276+
"child-dir/dependency/lib.apple.node/react-native-node-api-module": "",
277+
"child-dir/node_modules/dependency/lib.apple.node/react-native-node-api-module":
279278
"",
280279
});
281280
const result = findNodeApiModulePaths({
@@ -284,23 +283,23 @@ describe("findNodeApiModulePaths", () => {
284283
excludePatterns: [/root/],
285284
});
286285
assert.deepEqual(result.sort(), [
287-
path.join(tempDir, "child-dir/dependency/lib.xcframework"),
288-
path.join(tempDir, "child-dir/node_modules/dependency/lib.xcframework"),
286+
path.join(tempDir, "child-dir/dependency/lib.apple.node"),
287+
path.join(tempDir, "child-dir/node_modules/dependency/lib.apple.node"),
289288
]);
290289
});
291290

292291
it("disregards parts futher up in filesystem when excluding", (context) => {
293292
const tempDir = setupTempDirectory(context, {
294-
"node_modules/root.xcframework/react-native-node-api-module": "",
295-
"node_modules/child-dir/node_modules/dependency/lib.xcframework/react-native-node-api-module":
293+
"node_modules/root.apple.node/react-native-node-api-module": "",
294+
"node_modules/child-dir/node_modules/dependency/lib.apple.node/react-native-node-api-module":
296295
"",
297296
});
298297
const result = findNodeApiModulePaths({
299298
fromPath: path.join(tempDir, "node_modules"),
300299
platform: "apple",
301300
});
302301
assert.deepEqual(result, [
303-
path.join(tempDir, "node_modules/root.xcframework"),
302+
path.join(tempDir, "node_modules/root.apple.node"),
304303
]);
305304
});
306305
});
@@ -311,7 +310,7 @@ describe("determineModuleContext", () => {
311310
"package.json": `{ "name": "cached-pkg" }`,
312311
"subdir1/file1.node": "",
313312
"subdir2/file2.node": "",
314-
"subdir1/file1.xcframework": "",
313+
"subdir1/file1.apple.node": "",
315314
});
316315
let readCount = 0;
317316
const orig = fs.readFileSync;

0 commit comments

Comments
 (0)