diff options
Diffstat (limited to 'tests/integration/lsp_tests.rs')
-rw-r--r-- | tests/integration/lsp_tests.rs | 60 |
1 files changed, 54 insertions, 6 deletions
diff --git a/tests/integration/lsp_tests.rs b/tests/integration/lsp_tests.rs index f1a368413..09178cd46 100644 --- a/tests/integration/lsp_tests.rs +++ b/tests/integration/lsp_tests.rs @@ -80,12 +80,60 @@ fn lsp_tsconfig_types() { let mut client = context.new_lsp_command().build(); client.initialize(|builder| { - builder.set_config("types.tsconfig.json"); + builder + .set_config("types.tsconfig.json") + // avoid finding the declaration file via the document preload + .set_preload_limit(0); }); let diagnostics = client.did_open(json!({ "textDocument": { - "uri": Url::from_file_path(temp_dir.path().join("test.ts")).unwrap(), + "uri": temp_dir.uri().join("test.ts").unwrap(), + "languageId": "typescript", + "version": 1, + "text": "console.log(a);\n" + } + })); + + assert_eq!(diagnostics.all().len(), 0); + + client.shutdown(); +} + +#[test] +fn lsp_tsconfig_types_config_sub_dir() { + let context = TestContextBuilder::new().use_temp_cwd().build(); + let temp_dir = context.temp_dir(); + + let sub_dir = temp_dir.path().join("sub_dir"); + sub_dir.create_dir_all(); + sub_dir.join("types.tsconfig.json").write( + r#"{ + "compilerOptions": { + "types": ["./a.d.ts"] + }, + "lint": { + "rules": { + "tags": [] + } + } +}"#, + ); + let a_dts = "// deno-lint-ignore-file no-var\ndeclare var a: string;"; + sub_dir.join("a.d.ts").write(a_dts); + temp_dir.write("deno.json", "{}"); + + let mut client = context.new_lsp_command().build(); + client.initialize(|builder| { + builder + .set_config("sub_dir/types.tsconfig.json") + // avoid finding the declaration file via the document preload + .set_preload_limit(0); + }); + + let diagnostics = client.did_open(json!({ + "textDocument": { + "uri": temp_dir.uri().join("test.ts").unwrap(), "languageId": "typescript", "version": 1, "text": "console.log(a);\n" @@ -164,7 +212,7 @@ fn lsp_import_map() { builder.set_import_map("import-map.json"); }); - let uri = Url::from_file_path(temp_dir.path().join("a.ts")).unwrap(); + let uri = temp_dir.uri().join("a.ts").unwrap(); let diagnostics = client.did_open(json!({ "textDocument": { @@ -10801,7 +10849,7 @@ fn lsp_data_urls_with_jsx_compiler_option() { let mut client = context.new_lsp_command().build(); client.initialize_default(); - let uri = Url::from_file_path(temp_dir.path().join("main.ts")).unwrap(); + let uri = temp_dir.uri().join("main.ts").unwrap(); let diagnostics = client.did_open(json!({ "textDocument": { @@ -11683,7 +11731,7 @@ fn decorators_tc39() { let mut client = context.new_lsp_command().build(); client.initialize_default(); - let uri = Url::from_file_path(temp_dir.path().join("main.ts")).unwrap(); + let uri = temp_dir.uri().join("main.ts").unwrap(); let diagnostics = client .did_open(json!({ @@ -11734,7 +11782,7 @@ fn decorators_ts() { let mut client = context.new_lsp_command().build(); client.initialize_default(); - let uri = Url::from_file_path(temp_dir.path().join("main.ts")).unwrap(); + let uri = temp_dir.uri().join("main.ts").unwrap(); let diagnostics = client .did_open(json!({ |