Skip to content

Commit 9bb9eec

Browse files
author
Mariusz Pasinski
committed
feat: add test for scoped package names
1 parent 4dcf2fd commit 9bb9eec

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

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

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ describe("determineNormalizedModuleContext", () => {
167167
});
168168

169169
describe("determineModuleContext", () => {
170-
it("resolves the correct package name", (context) => {
170+
it("resolves the correct unscoped package name", (context) => {
171171
const tempDirectoryPath = setupTempDirectory(context, {
172172
"package.json": `{ "name": "root-package" }`,
173173
// Two sub-packages with the same name
@@ -191,6 +191,31 @@ describe("determineModuleContext", () => {
191191
assert.equal(relativePath, "some-file.node");
192192
}
193193
});
194+
195+
it("resolves the correct scoped package name", (context) => {
196+
const tempDirectoryPath = setupTempDirectory(context, {
197+
"package.json": `{ "name": "root-package" }`,
198+
// Two sub-packages with the same name
199+
"sub-package-a/package.json": `{ "name": "@root-package/my-sub-package-a" }`,
200+
"sub-package-b/package.json": `{ "name": "@root-package/my-sub-package-b" }`,
201+
});
202+
203+
{
204+
const { packageName, relativePath } = determineModuleContext(
205+
path.join(tempDirectoryPath, "sub-package-a/some-file.node")
206+
);
207+
assert.equal(packageName, "@root-package/my-sub-package-a");
208+
assert.equal(relativePath, "some-file.node");
209+
}
210+
211+
{
212+
const { packageName, relativePath } = determineModuleContext(
213+
path.join(tempDirectoryPath, "sub-package-b/some-file.node")
214+
);
215+
assert.equal(packageName, "@root-package/my-sub-package-b");
216+
assert.equal(relativePath, "some-file.node");
217+
}
218+
});
194219
});
195220

196221
describe("getLibraryName", () => {

0 commit comments

Comments
 (0)