Skip to content

Commit 4445c07

Browse files
author
Mariusz Pasinski
committed
feat: add test for scoped package names
1 parent 5cc7258 commit 4445c07

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
@@ -145,7 +145,7 @@ describe("determineNormalizedModuleContext", () => {
145145
});
146146

147147
describe("determineModuleContext", () => {
148-
it("resolves the correct package name", (context) => {
148+
it("resolves the correct unscoped package name", (context) => {
149149
const tempDirectoryPath = setupTempDirectory(context, {
150150
"package.json": `{ "name": "root-package" }`,
151151
// Two sub-packages with the same name
@@ -169,6 +169,31 @@ describe("determineModuleContext", () => {
169169
assert.equal(relativePath, "some-file.node");
170170
}
171171
});
172+
173+
it("resolves the correct scoped package name", (context) => {
174+
const tempDirectoryPath = setupTempDirectory(context, {
175+
"package.json": `{ "name": "root-package" }`,
176+
// Two sub-packages with the same name
177+
"sub-package-a/package.json": `{ "name": "@root-package/my-sub-package-a" }`,
178+
"sub-package-b/package.json": `{ "name": "@root-package/my-sub-package-b" }`,
179+
});
180+
181+
{
182+
const { packageName, relativePath } = determineModuleContext(
183+
path.join(tempDirectoryPath, "sub-package-a/some-file.node")
184+
);
185+
assert.equal(packageName, "@root-package/my-sub-package-a");
186+
assert.equal(relativePath, "some-file.node");
187+
}
188+
189+
{
190+
const { packageName, relativePath } = determineModuleContext(
191+
path.join(tempDirectoryPath, "sub-package-b/some-file.node")
192+
);
193+
assert.equal(packageName, "@root-package/my-sub-package-b");
194+
assert.equal(relativePath, "some-file.node");
195+
}
196+
});
172197
});
173198

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

0 commit comments

Comments
 (0)