diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/integration/lsp_tests.rs | 53 | ||||
-rw-r--r-- | tests/testdata/jsr/registry/@denotest/add/0.2.0/mod.ts | 4 | ||||
-rw-r--r-- | tests/testdata/jsr/registry/@denotest/add/0.2.0_meta.json | 8 | ||||
-rw-r--r-- | tests/testdata/jsr/registry/@denotest/add/meta.json | 3 |
4 files changed, 64 insertions, 4 deletions
diff --git a/tests/integration/lsp_tests.rs b/tests/integration/lsp_tests.rs index 7d1022176..749af95c4 100644 --- a/tests/integration/lsp_tests.rs +++ b/tests/integration/lsp_tests.rs @@ -4664,9 +4664,6 @@ fn lsp_code_actions_deno_cache_jsr() { .use_temp_cwd() .build(); let temp_dir = context.temp_dir(); - // TODO(nayeemrmn): JSR resolution currently depends on a lockfile being - // created on cache. Remove this when that's not the case. - temp_dir.write("deno.json", "{}"); let mut client = context.new_lsp_command().build(); client.initialize_default(); let diagnostics = client.did_open(json!({ @@ -4764,6 +4761,56 @@ fn lsp_code_actions_deno_cache_jsr() { } #[test] +fn lsp_jsr_lockfile() { + let context = TestContextBuilder::new() + .use_http_server() + .use_temp_cwd() + .build(); + let temp_dir = context.temp_dir(); + temp_dir.write("./deno.json", json!({}).to_string()); + temp_dir.write( + "./deno.lock", + json!({ + "version": "3", + "packages": { + "specifiers": { + // This is an old version of the package which exports `sum()` instead + // of `add()`. + "jsr:@denotest/add": "jsr:@denotest/add@0.2.0", + }, + }, + }) + .to_string(), + ); + let mut client = context.new_lsp_command().build(); + client.initialize_default(); + client.did_open(json!({ + "textDocument": { + "uri": temp_dir.uri().join("file.ts").unwrap(), + "languageId": "typescript", + "version": 1, + "text": r#" + import { add } from "jsr:@denotest/add"; + console.log(add(1, 2)); + "#, + }, + })); + client.write_request( + "workspace/executeCommand", + json!({ + "command": "deno.cache", + "arguments": [ + [], + temp_dir.uri().join("file.ts").unwrap(), + ], + }), + ); + let diagnostics = client.read_diagnostics(); + assert_eq!(json!(diagnostics.all()), json!([])); + client.shutdown(); +} + +#[test] fn lsp_code_actions_deno_cache_npm() { let context = TestContextBuilder::new().use_temp_cwd().build(); let mut client = context.new_lsp_command().build(); diff --git a/tests/testdata/jsr/registry/@denotest/add/0.2.0/mod.ts b/tests/testdata/jsr/registry/@denotest/add/0.2.0/mod.ts new file mode 100644 index 000000000..864e8dd32 --- /dev/null +++ b/tests/testdata/jsr/registry/@denotest/add/0.2.0/mod.ts @@ -0,0 +1,4 @@ +// This is renamed to `add()` in 1.0.0. +export function sum(a: number, b: number): number { + return a + b; +} diff --git a/tests/testdata/jsr/registry/@denotest/add/0.2.0_meta.json b/tests/testdata/jsr/registry/@denotest/add/0.2.0_meta.json new file mode 100644 index 000000000..6eebe2198 --- /dev/null +++ b/tests/testdata/jsr/registry/@denotest/add/0.2.0_meta.json @@ -0,0 +1,8 @@ +{ + "exports": { + ".": "./mod.ts" + }, + "moduleGraph1": { + "/mod.ts": {} + } +} diff --git a/tests/testdata/jsr/registry/@denotest/add/meta.json b/tests/testdata/jsr/registry/@denotest/add/meta.json index 02601e4d0..2f4daa844 100644 --- a/tests/testdata/jsr/registry/@denotest/add/meta.json +++ b/tests/testdata/jsr/registry/@denotest/add/meta.json @@ -1,5 +1,6 @@ { "versions": { - "1.0.0": {} + "1.0.0": {}, + "0.2.0": {} } } |