diff options
Diffstat (limited to 'cli/tests/integration/lsp_tests.rs')
-rw-r--r-- | cli/tests/integration/lsp_tests.rs | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/cli/tests/integration/lsp_tests.rs b/cli/tests/integration/lsp_tests.rs index bd5bc409a..b6ed08e30 100644 --- a/cli/tests/integration/lsp_tests.rs +++ b/cli/tests/integration/lsp_tests.rs @@ -360,6 +360,79 @@ fn lsp_import_map_embedded_in_config_file() { } #[test] +fn lsp_import_map_embedded_in_config_file_after_initialize() { + let context = TestContextBuilder::new().use_temp_cwd().build(); + let temp_dir = context.temp_dir(); + temp_dir.write("deno.embedded_import_map.jsonc", "{}"); + temp_dir.create_dir_all("lib"); + temp_dir.write("lib/b.ts", r#"export const b = "b";"#); + + let mut client = context.new_lsp_command().build(); + client.initialize(|builder| { + builder.set_config("./deno.embedded_import_map.jsonc"); + }); + + let uri = temp_dir.uri().join("a.ts").unwrap(); + + let diagnostics = client.did_open(json!({ + "textDocument": { + "uri": uri, + "languageId": "typescript", + "version": 1, + "text": "import { b } from \"/~/b.ts\";\n\nconsole.log(b);\n" + } + })); + + assert_eq!(diagnostics.all().len(), 1); + + // update the import map + temp_dir.write( + "deno.embedded_import_map.jsonc", + r#"{ + "imports": { + "/~/": "./lib/" + } +}"#, + ); + + client.did_change_watched_files(json!({ + "changes": [{ + "uri": temp_dir.uri().join("deno.embedded_import_map.jsonc").unwrap(), + "type": 2 + }] + })); + + assert_eq!(client.read_diagnostics().all().len(), 0); + + let res = client.write_request( + "textDocument/hover", + json!({ + "textDocument": { + "uri": uri + }, + "position": { "line": 2, "character": 12 } + }), + ); + assert_eq!( + res, + json!({ + "contents": [ + { + "language": "typescript", + "value":"(alias) const b: \"b\"\nimport b" + }, + "" + ], + "range": { + "start": { "line": 2, "character": 12 }, + "end": { "line": 2, "character": 13 } + } + }) + ); + client.shutdown(); +} + +#[test] fn lsp_deno_task() { let context = TestContextBuilder::new().use_temp_cwd().build(); let temp_dir = context.temp_dir(); |