Skip to content

Commit

Permalink
WIP: fix: resolve jsr import with path correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
hasundue committed Mar 21, 2024
1 parent d3d386e commit c490ce0
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions lib/import_map_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ describe("readFromJson", () => {
});
});

describe("resolve()", () => {
describe("resolve", () => {
it("resolve specifiers in import maps", async () => {
const importMap = await readFromJson(
new URL("../test/data/import_map/deno.json", import.meta.url),
Expand Down Expand Up @@ -64,6 +64,14 @@ describe("resolve()", () => {
value: "npm:node-emoji@2.0.0",
},
);
assertEquals(
importMap.resolve("@std/testing/bdd", referrer),
{
resolved: "jsr:@std/testing@0.200.0/bdd",
key: "@std/testing",
value: "jsr:@std/testing@0.200.0",
},
);
assertEquals(
importMap.resolve("/lib.ts", referrer),
{
Expand Down Expand Up @@ -121,11 +129,13 @@ Deno.test("resolveInner", async () => {
const { resolveInner } = await readFromJson(
new URL("../test/data/import_map/deno.json", import.meta.url),
);
const referrer = new URL("../test/data/import_map/mod.ts", import.meta.url);
assertEquals(
resolveInner(
"/lib.ts",
new URL("../test/data/import_map/mod.ts", import.meta.url),
),
resolveInner("/lib.ts", referrer),
new URL("../test/data/import_map/lib.ts", import.meta.url).href,
);
assertEquals(
resolveInner("@std/testing/bdd", referrer),
"jsr:/@std/testing@0.200.0/bdd",
);
});

0 comments on commit c490ce0

Please sign in to comment.