From c490ce054aee4b7c58e64560def55736160eac97 Mon Sep 17 00:00:00 2001 From: hasundue Date: Thu, 21 Mar 2024 10:17:46 +0900 Subject: [PATCH] WIP: fix: resolve jsr import with path correctly --- lib/import_map_test.ts | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/lib/import_map_test.ts b/lib/import_map_test.ts index 9ccafe85..29cb4bcb 100644 --- a/lib/import_map_test.ts +++ b/lib/import_map_test.ts @@ -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), @@ -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), { @@ -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", + ); });