summaryrefslogtreecommitdiff
path: root/tests/integration/lsp_tests.rs
diff options
context:
space:
mode:
authorNayeem Rahman <nayeemrmn99@gmail.com>2024-02-14 22:48:39 +0000
committerGitHub <noreply@github.com>2024-02-14 22:48:39 +0000
commit1ad754b4123009e01dbecb3b880e7f0545e46c2f (patch)
tree400ef028fc459827b3c9e0faded780d853531da5 /tests/integration/lsp_tests.rs
parent66baff763fad65e8b209763d5c8d16084a3ab60c (diff)
feat(lsp): jsr support with cache probing (#22418)
Diffstat (limited to 'tests/integration/lsp_tests.rs')
-rw-r--r--tests/integration/lsp_tests.rs53
1 files changed, 50 insertions, 3 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();