summaryrefslogtreecommitdiff
path: root/cli/tests/integration_tests_lsp.rs
diff options
context:
space:
mode:
Diffstat (limited to 'cli/tests/integration_tests_lsp.rs')
-rw-r--r--cli/tests/integration_tests_lsp.rs80
1 files changed, 79 insertions, 1 deletions
diff --git a/cli/tests/integration_tests_lsp.rs b/cli/tests/integration_tests_lsp.rs
index e36de9ae3..0d203c7f8 100644
--- a/cli/tests/integration_tests_lsp.rs
+++ b/cli/tests/integration_tests_lsp.rs
@@ -45,7 +45,15 @@ where
let (id, method, _) = client.read_request::<Value>().unwrap();
assert_eq!(method, "workspace/configuration");
client
- .write_response(id, json!({ "enable": true }))
+ .write_response(
+ id,
+ json!({
+ "enable": true,
+ "codeLens": {
+ "test": true
+ }
+ }),
+ )
.unwrap();
let mut diagnostics = vec![];
@@ -1230,6 +1238,76 @@ fn lsp_code_lens_impl() {
}
#[test]
+fn lsp_code_lens_test() {
+ let mut client = init("initialize_params_code_lens_test.json");
+ did_open(
+ &mut client,
+ load_fixture("did_open_params_test_code_lens.json"),
+ );
+ let (maybe_res, maybe_err) = client
+ .write_request(
+ "textDocument/codeLens",
+ json!({
+ "textDocument": {
+ "uri": "file:///a/file.ts"
+ }
+ }),
+ )
+ .unwrap();
+ assert!(maybe_err.is_none());
+ assert_eq!(
+ maybe_res,
+ Some(load_fixture("code_lens_response_test.json"))
+ );
+ shutdown(&mut client);
+}
+
+#[test]
+fn lsp_code_lens_test_disabled() {
+ let mut client = init("initialize_params_code_lens_test_disabled.json");
+ client
+ .write_notification(
+ "textDocument/didOpen",
+ load_fixture("did_open_params_test_code_lens.json"),
+ )
+ .unwrap();
+
+ let (id, method, _) = client.read_request::<Value>().unwrap();
+ assert_eq!(method, "workspace/configuration");
+ client
+ .write_response(
+ id,
+ json!({
+ "enable": true,
+ "codeLens": {
+ "test": false
+ }
+ }),
+ )
+ .unwrap();
+
+ let (method, _) = client.read_notification::<Value>().unwrap();
+ assert_eq!(method, "textDocument/publishDiagnostics");
+ let (method, _) = client.read_notification::<Value>().unwrap();
+ assert_eq!(method, "textDocument/publishDiagnostics");
+ let (method, _) = client.read_notification::<Value>().unwrap();
+ assert_eq!(method, "textDocument/publishDiagnostics");
+ let (maybe_res, maybe_err) = client
+ .write_request(
+ "textDocument/codeLens",
+ json!({
+ "textDocument": {
+ "uri": "file:///a/file.ts"
+ }
+ }),
+ )
+ .unwrap();
+ assert!(maybe_err.is_none());
+ assert_eq!(maybe_res, Some(json!([])));
+ shutdown(&mut client);
+}
+
+#[test]
fn lsp_code_lens_non_doc_nav_tree() {
let mut client = init("initialize_params.json");
did_open(