summaryrefslogtreecommitdiff
path: root/cli/tests
diff options
context:
space:
mode:
Diffstat (limited to 'cli/tests')
-rw-r--r--cli/tests/integration_tests_lsp.rs80
-rw-r--r--cli/tests/lsp/code_lens_response_test.json162
-rw-r--r--cli/tests/lsp/did_open_params_test_code_lens.json8
-rw-r--r--cli/tests/lsp/initialize_params.json3
-rw-r--r--cli/tests/lsp/initialize_params_code_lens_test.json56
-rw-r--r--cli/tests/lsp/initialize_params_code_lens_test_disabled.json61
6 files changed, 368 insertions, 2 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(
diff --git a/cli/tests/lsp/code_lens_response_test.json b/cli/tests/lsp/code_lens_response_test.json
new file mode 100644
index 000000000..b2cb4588a
--- /dev/null
+++ b/cli/tests/lsp/code_lens_response_test.json
@@ -0,0 +1,162 @@
+[
+ {
+ "range": {
+ "start": {
+ "line": 4,
+ "character": 5
+ },
+ "end": {
+ "line": 4,
+ "character": 9
+ }
+ },
+ "command": {
+ "title": "▶︎ Run Test",
+ "command": "deno.test",
+ "arguments": [
+ "file:///a/file.ts",
+ "test a"
+ ]
+ }
+ },
+ {
+ "range": {
+ "start": {
+ "line": 5,
+ "character": 5
+ },
+ "end": {
+ "line": 5,
+ "character": 9
+ }
+ },
+ "command": {
+ "title": "▶︎ Run Test",
+ "command": "deno.test",
+ "arguments": [
+ "file:///a/file.ts",
+ "test b"
+ ]
+ }
+ },
+ {
+ "range": {
+ "start": {
+ "line": 9,
+ "character": 0
+ },
+ "end": {
+ "line": 9,
+ "character": 4
+ }
+ },
+ "command": {
+ "title": "▶︎ Run Test",
+ "command": "deno.test",
+ "arguments": [
+ "file:///a/file.ts",
+ "test c"
+ ]
+ }
+ },
+ {
+ "range": {
+ "start": {
+ "line": 13,
+ "character": 0
+ },
+ "end": {
+ "line": 13,
+ "character": 4
+ }
+ },
+ "command": {
+ "title": "▶︎ Run Test",
+ "command": "deno.test",
+ "arguments": [
+ "file:///a/file.ts",
+ "test d"
+ ]
+ }
+ },
+ {
+ "range": {
+ "start": {
+ "line": 14,
+ "character": 0
+ },
+ "end": {
+ "line": 14,
+ "character": 5
+ }
+ },
+ "command": {
+ "title": "▶︎ Run Test",
+ "command": "deno.test",
+ "arguments": [
+ "file:///a/file.ts",
+ "test e"
+ ]
+ }
+ },
+ {
+ "range": {
+ "start": {
+ "line": 18,
+ "character": 0
+ },
+ "end": {
+ "line": 18,
+ "character": 5
+ }
+ },
+ "command": {
+ "title": "▶︎ Run Test",
+ "command": "deno.test",
+ "arguments": [
+ "file:///a/file.ts",
+ "test f"
+ ]
+ }
+ },
+ {
+ "range": {
+ "start": {
+ "line": 19,
+ "character": 0
+ },
+ "end": {
+ "line": 19,
+ "character": 5
+ }
+ },
+ "command": {
+ "title": "▶︎ Run Test",
+ "command": "deno.test",
+ "arguments": [
+ "file:///a/file.ts",
+ "test g"
+ ]
+ }
+ },
+ {
+ "range": {
+ "start": {
+ "line": 23,
+ "character": 0
+ },
+ "end": {
+ "line": 23,
+ "character": 5
+ }
+ },
+ "command": {
+ "title": "▶︎ Run Test",
+ "command": "deno.test",
+ "arguments": [
+ "file:///a/file.ts",
+ "test h"
+ ]
+ }
+ }
+]
diff --git a/cli/tests/lsp/did_open_params_test_code_lens.json b/cli/tests/lsp/did_open_params_test_code_lens.json
new file mode 100644
index 000000000..dcb9e11f3
--- /dev/null
+++ b/cli/tests/lsp/did_open_params_test_code_lens.json
@@ -0,0 +1,8 @@
+{
+ "textDocument": {
+ "uri": "file:///a/file.ts",
+ "languageId": "typescript",
+ "version": 1,
+ "text": "const { test } = Deno;\nconst { test: test2 } = Deno;\nconst test3 = Deno.test;\n\nDeno.test(\"test a\", () => {});\nDeno.test({\n name: \"test b\",\n fn() {},\n});\ntest({\n name: \"test c\",\n fn() {},\n});\ntest(\"test d\", () => {});\ntest2({\n name: \"test e\",\n fn() {},\n});\ntest2(\"test f\", () => {});\ntest3({\n name: \"test g\",\n fn() {},\n});\ntest3(\"test h\", () => {});\n"
+ }
+}
diff --git a/cli/tests/lsp/initialize_params.json b/cli/tests/lsp/initialize_params.json
index 98ec53aa6..01b334cd5 100644
--- a/cli/tests/lsp/initialize_params.json
+++ b/cli/tests/lsp/initialize_params.json
@@ -9,7 +9,8 @@
"enable": true,
"codeLens": {
"implementations": true,
- "references": true
+ "references": true,
+ "test": true
},
"importMap": null,
"lint": true,
diff --git a/cli/tests/lsp/initialize_params_code_lens_test.json b/cli/tests/lsp/initialize_params_code_lens_test.json
new file mode 100644
index 000000000..792928462
--- /dev/null
+++ b/cli/tests/lsp/initialize_params_code_lens_test.json
@@ -0,0 +1,56 @@
+{
+ "processId": 0,
+ "clientInfo": {
+ "name": "test-harness",
+ "version": "1.0.0"
+ },
+ "rootUri": null,
+ "initializationOptions": {
+ "enable": true,
+ "importMap": null,
+ "lint": true,
+ "suggest": {
+ "autoImports": true,
+ "completeFunctionCalls": false,
+ "names": true,
+ "paths": true,
+ "imports": {
+ "hosts": {}
+ }
+ },
+ "unstable": false
+ },
+ "capabilities": {
+ "textDocument": {
+ "codeAction": {
+ "codeActionLiteralSupport": {
+ "codeActionKind": {
+ "valueSet": [
+ "quickfix"
+ ]
+ }
+ },
+ "isPreferredSupport": true,
+ "dataSupport": true,
+ "resolveSupport": {
+ "properties": [
+ "edit"
+ ]
+ }
+ },
+ "foldingRange": {
+ "lineFoldingOnly": true
+ },
+ "synchronization": {
+ "dynamicRegistration": true,
+ "willSave": true,
+ "willSaveWaitUntil": true,
+ "didSave": true
+ }
+ },
+ "workspace": {
+ "configuration": true,
+ "workspaceFolders": true
+ }
+ }
+}
diff --git a/cli/tests/lsp/initialize_params_code_lens_test_disabled.json b/cli/tests/lsp/initialize_params_code_lens_test_disabled.json
new file mode 100644
index 000000000..febec5695
--- /dev/null
+++ b/cli/tests/lsp/initialize_params_code_lens_test_disabled.json
@@ -0,0 +1,61 @@
+{
+ "processId": 0,
+ "clientInfo": {
+ "name": "test-harness",
+ "version": "1.0.0"
+ },
+ "rootUri": null,
+ "initializationOptions": {
+ "enable": true,
+ "codeLens": {
+ "implementations": true,
+ "references": true,
+ "test": false
+ },
+ "importMap": null,
+ "lint": true,
+ "suggest": {
+ "autoImports": true,
+ "completeFunctionCalls": false,
+ "names": true,
+ "paths": true,
+ "imports": {
+ "hosts": {}
+ }
+ },
+ "unstable": false
+ },
+ "capabilities": {
+ "textDocument": {
+ "codeAction": {
+ "codeActionLiteralSupport": {
+ "codeActionKind": {
+ "valueSet": [
+ "quickfix"
+ ]
+ }
+ },
+ "isPreferredSupport": true,
+ "dataSupport": true,
+ "resolveSupport": {
+ "properties": [
+ "edit"
+ ]
+ }
+ },
+ "foldingRange": {
+ "lineFoldingOnly": true
+ },
+ "synchronization": {
+ "dynamicRegistration": true,
+ "willSave": true,
+ "willSaveWaitUntil": true,
+ "didSave": true
+ }
+ },
+ "workspace": {
+ "configuration": true,
+ "workspaceFolders": true
+ }
+ }
+}