From bb5bf91067e28cef869f5180dc73a9b86e368bdc Mon Sep 17 00:00:00 2001 From: Kitson Kelly Date: Tue, 1 Jun 2021 21:53:08 +1000 Subject: feat(lsp): registry auto discovery (#10813) Closes: #10194 Fixes: #10468 --- cli/tests/integration_tests_lsp.rs | 47 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) (limited to 'cli/tests') diff --git a/cli/tests/integration_tests_lsp.rs b/cli/tests/integration_tests_lsp.rs index 999d2de71..e4b963f2b 100644 --- a/cli/tests/integration_tests_lsp.rs +++ b/cli/tests/integration_tests_lsp.rs @@ -1839,6 +1839,53 @@ fn lsp_completions_registry_empty() { shutdown(&mut client); } +#[test] +fn lsp_auto_discover_registry() { + let _g = http_server(); + let mut client = init("initialize_params.json"); + did_open( + &mut client, + json!({ + "textDocument": { + "uri": "file:///a/file.ts", + "languageId": "typescript", + "version": 1, + "text": "import * as a from \"http://localhost:4545/x/a@\"" + } + }), + ); + let (maybe_res, maybe_err) = client + .write_request::<_, _, Value>( + "textDocument/completion", + json!({ + "textDocument": { + "uri": "file:///a/file.ts" + }, + "position": { + "line": 0, + "character": 46 + }, + "context": { + "triggerKind": 2, + "triggerCharacter": "@" + } + }), + ) + .unwrap(); + assert!(maybe_err.is_none()); + assert!(maybe_res.is_some()); + let (method, maybe_res) = client.read_notification().unwrap(); + assert_eq!(method, "deno/registryState"); + assert_eq!( + maybe_res, + Some(json!({ + "origin": "http://localhost:4545", + "suggestions": true, + })) + ); + shutdown(&mut client); +} + #[test] fn lsp_diagnostics_warn() { let _g = http_server(); -- cgit v1.2.3