Skip to content

Commit

Permalink
chore: add graphql lookupNodeModuleSubpath test
Browse files Browse the repository at this point in the history
  • Loading branch information
productdevbook committed Dec 26, 2023
1 parent f24a0c3 commit 4344174
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/resolve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,9 @@ export async function lookupNodeModuleSubpath(
path: string,
): Promise<string | undefined> {
path = normalize(fileURLToPath(path));
console.log(path);
const { name, subpath } = parseNodeModulePath(path);

console.log({ name, subpath });
if (!name || !subpath) {
return subpath;
}
Expand Down
1 change: 1 addition & 0 deletions test/fixture/package/node_modules/graphql/cjs/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions test/fixture/package/node_modules/graphql/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions test/fixture/package/node_modules/graphql/src/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions test/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,17 @@ describe("lookupNodeModuleSubpath", () => {
input: r("fixture/package/node_modules/subpaths/"),
output: "./",
},
{
name: "resolves main export",
input: r("fixture/package/node_modules/graphql/src/index.js"),
output: "import",
},
];

for (const t of tests) {
it(t.name, async () => {
const result = await lookupNodeModuleSubpath(t.input);
console.log(result);
expect(result).toBe(t.output);
});
}
Expand Down

0 comments on commit 4344174

Please sign in to comment.