summaryrefslogtreecommitdiff
path: root/cli/tests
diff options
context:
space:
mode:
Diffstat (limited to 'cli/tests')
-rw-r--r--cli/tests/integration_tests_lsp.rs62
-rw-r--r--cli/tests/lsp/lib.tsconfig.json5
2 files changed, 60 insertions, 7 deletions
diff --git a/cli/tests/integration_tests_lsp.rs b/cli/tests/integration_tests_lsp.rs
index 10797a326..b6d9cde54 100644
--- a/cli/tests/integration_tests_lsp.rs
+++ b/cli/tests/integration_tests_lsp.rs
@@ -31,7 +31,10 @@ fn init(init_path: &str) -> LspClient {
client
}
-fn did_open<V>(client: &mut LspClient, params: V)
+fn did_open<V>(
+ client: &mut LspClient,
+ params: V,
+) -> Vec<lsp::PublishDiagnosticsParams>
where
V: Serialize,
{
@@ -45,12 +48,16 @@ where
.write_response(id, json!({ "enable": true }))
.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 mut diagnostics = vec![];
+ for _ in 0..3 {
+ let (method, response) = client
+ .read_notification::<lsp::PublishDiagnosticsParams>()
+ .unwrap();
+ assert_eq!(method, "textDocument/publishDiagnostics");
+ diagnostics.push(response.unwrap());
+ }
+
+ diagnostics
}
fn shutdown(client: &mut LspClient) {
@@ -67,6 +74,47 @@ fn lsp_startup_shutdown() {
}
#[test]
+fn lsp_init_tsconfig() {
+ let temp_dir = TempDir::new().expect("could not create temp dir");
+ let mut params: lsp::InitializeParams =
+ serde_json::from_value(load_fixture("initialize_params.json")).unwrap();
+ let tsconfig =
+ serde_json::to_vec_pretty(&load_fixture("lib.tsconfig.json")).unwrap();
+ fs::write(temp_dir.path().join("lib.tsconfig.json"), tsconfig).unwrap();
+
+ params.root_uri = Some(Url::from_file_path(temp_dir.path()).unwrap());
+ if let Some(Value::Object(mut map)) = params.initialization_options {
+ map.insert("config".to_string(), json!("./lib.tsconfig.json"));
+ params.initialization_options = Some(Value::Object(map));
+ }
+
+ let deno_exe = deno_exe_path();
+ let mut client = LspClient::new(&deno_exe).unwrap();
+ client
+ .write_request::<_, _, Value>("initialize", params)
+ .unwrap();
+
+ client.write_notification("initialized", json!({})).unwrap();
+
+ let diagnostics = did_open(
+ &mut client,
+ json!({
+ "textDocument": {
+ "uri": "file:///a/file.ts",
+ "languageId": "typescript",
+ "version": 1,
+ "text": "location.pathname;\n"
+ }
+ }),
+ );
+
+ let diagnostics = diagnostics.into_iter().flat_map(|x| x.diagnostics);
+ assert_eq!(diagnostics.count(), 0);
+
+ shutdown(&mut client);
+}
+
+#[test]
fn lsp_hover() {
let mut client = init("initialize_params.json");
did_open(
diff --git a/cli/tests/lsp/lib.tsconfig.json b/cli/tests/lsp/lib.tsconfig.json
new file mode 100644
index 000000000..8d2ae8a8b
--- /dev/null
+++ b/cli/tests/lsp/lib.tsconfig.json
@@ -0,0 +1,5 @@
+{
+ "compilerOptions": {
+ "lib": ["deno.ns", "deno.unstable", "dom"]
+ }
+}