From fb45d481a0e4e9d1644487ed18af7246b5815176 Mon Sep 17 00:00:00 2001 From: hasundue Date: Tue, 12 Mar 2024 13:36:41 +0900 Subject: [PATCH] test: add a failing case (mapped jsr with path) --- core/import_map_test.ts | 10 ++++---- .../jsr_with_path_in_import_map/deno.json | 5 ++++ test/cases/jsr_with_path_in_import_map/mod.ts | 1 + test/snapshots/update_test.ts.snap | 23 +++++++++++++++++++ 4 files changed, 35 insertions(+), 4 deletions(-) create mode 100644 test/cases/jsr_with_path_in_import_map/deno.json create mode 100644 test/cases/jsr_with_path_in_import_map/mod.ts diff --git a/core/import_map_test.ts b/core/import_map_test.ts index c12e2104..0fe7ea50 100644 --- a/core/import_map_test.ts +++ b/core/import_map_test.ts @@ -124,11 +124,13 @@ Deno.test("resolveInner", async () => { const { resolveInner } = await readFromJson( new URL("../test/cases/import_map/deno.json", import.meta.url), ); + const referrer = new URL("../test/cases/import_map/mod.ts", import.meta.url); assertEquals( - resolveInner( - "/lib.ts", - new URL("../test/cases/import_map/mod.ts", import.meta.url), - ), + resolveInner("/lib.ts", referrer), new URL("../test/cases/import_map/lib.ts", import.meta.url).href, ); + assertEquals( + resolveInner("@std/testing/bdd", referrer), + "jsr:/@std/testing@0.200.0/bdd", + ); }); diff --git a/test/cases/jsr_with_path_in_import_map/deno.json b/test/cases/jsr_with_path_in_import_map/deno.json new file mode 100644 index 00000000..5d128d6b --- /dev/null +++ b/test/cases/jsr_with_path_in_import_map/deno.json @@ -0,0 +1,5 @@ +{ + "imports": { + "@std/testing": "jsr:@std/testing@0.210.0" + } +} diff --git a/test/cases/jsr_with_path_in_import_map/mod.ts b/test/cases/jsr_with_path_in_import_map/mod.ts new file mode 100644 index 00000000..df2a9225 --- /dev/null +++ b/test/cases/jsr_with_path_in_import_map/mod.ts @@ -0,0 +1 @@ +import { describe } from "@std/testing/bdd"; diff --git a/test/snapshots/update_test.ts.snap b/test/snapshots/update_test.ts.snap index a8d55b80..a35323a0 100644 --- a/test/snapshots/update_test.ts.snap +++ b/test/snapshots/update_test.ts.snap @@ -96,6 +96,29 @@ snapshot[`collect - lockfile_not_importable - mod.ts 2`] = ` ] `; +snapshot[`collect - jsr_with_path_in_import_map - deno.json 1`] = ` +[ + { + code: { + span: undefined, + specifier: "jsr:@std/testing@0.210.0", + }, + from: { + name: "@std/testing", + path: "", + protocol: "jsr:", + version: "0.210.0", + }, + to: { + name: "@std/testing", + path: "", + protocol: "jsr:", + version: "123.456.789", + }, + }, +] +`; + snapshot[`collect - multiple_imports.ts 1`] = ` [ {