summaryrefslogtreecommitdiff
path: root/cli/tests/integration_tests_lsp.rs
diff options
context:
space:
mode:
authorKitson Kelly <me@kitsonkelly.com>2021-06-01 19:24:36 +1000
committerGitHub <noreply@github.com>2021-06-01 19:24:36 +1000
commit9abb899f5fd36da65aae78351df3f478f8363700 (patch)
tree8948798d0e38eee9ebcdf6ecdd578e01f215bdd5 /cli/tests/integration_tests_lsp.rs
parente466a6fc9ade08c8ca17322d47017709eecc4444 (diff)
fix(lsp): updates to workspace config are processed sync (#10812)
Diffstat (limited to 'cli/tests/integration_tests_lsp.rs')
-rw-r--r--cli/tests/integration_tests_lsp.rs90
1 files changed, 90 insertions, 0 deletions
diff --git a/cli/tests/integration_tests_lsp.rs b/cli/tests/integration_tests_lsp.rs
index 744b8d387..999d2de71 100644
--- a/cli/tests/integration_tests_lsp.rs
+++ b/cli/tests/integration_tests_lsp.rs
@@ -2125,3 +2125,93 @@ fn lsp_format_markdown() {
);
shutdown(&mut client);
}
+
+#[test]
+fn lsp_configuration_did_change() {
+ let _g = http_server();
+ let mut client = init("initialize_params_did_config_change.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@\""
+ }
+ }),
+ );
+ client
+ .write_notification(
+ "workspace/didChangeConfiguration",
+ json!({
+ "settings": {}
+ }),
+ )
+ .unwrap();
+ let (id, method, _) = client.read_request::<Value>().unwrap();
+ assert_eq!(method, "workspace/configuration");
+ client
+ .write_response(
+ id,
+ json!([{
+ "enable": true,
+ "codeLens": {
+ "implementations": true,
+ "references": true
+ },
+ "importMap": null,
+ "lint": true,
+ "suggest": {
+ "autoImports": true,
+ "completeFunctionCalls": false,
+ "names": true,
+ "paths": true,
+ "imports": {
+ "hosts": {
+ "http://localhost:4545/": true
+ }
+ }
+ },
+ "unstable": false
+ }]),
+ )
+ .unwrap();
+ let (maybe_res, maybe_err) = client
+ .write_request(
+ "textDocument/completion",
+ json!({
+ "textDocument": {
+ "uri": "file:///a/file.ts"
+ },
+ "position": {
+ "line": 0,
+ "character": 46
+ },
+ "context": {
+ "triggerKind": 2,
+ "triggerCharacter": "@"
+ }
+ }),
+ )
+ .unwrap();
+ assert!(maybe_err.is_none());
+ if let Some(lsp::CompletionResponse::List(list)) = maybe_res {
+ assert!(!list.is_incomplete);
+ assert_eq!(list.items.len(), 3);
+ } else {
+ panic!("unexpected response");
+ }
+ let (maybe_res, maybe_err) = client
+ .write_request(
+ "completionItem/resolve",
+ load_fixture("completion_resolve_params_registry.json"),
+ )
+ .unwrap();
+ assert!(maybe_err.is_none());
+ assert_eq!(
+ maybe_res,
+ Some(load_fixture("completion_resolve_response_registry.json"))
+ );
+ shutdown(&mut client);
+}