diff options
author | Kitson Kelly <me@kitsonkelly.com> | 2021-05-18 20:19:52 +1000 |
---|---|---|
committer | Bert Belder <bertbelder@gmail.com> | 2021-05-31 16:37:28 +0200 |
commit | d987ca5b0767d75b59b7c6c16840b164a4c786c4 (patch) | |
tree | ba7605219785ea1ec4e3b33109de1d2bcd2d866d /cli/tests/integration_tests_lsp.rs | |
parent | 6966c4e9166a0dc7e545fcec21d096f077cca996 (diff) |
feat(lsp): provide X-Deno-Warning as a diagnostic (#10680)
Closes #9932
Diffstat (limited to 'cli/tests/integration_tests_lsp.rs')
-rw-r--r-- | cli/tests/integration_tests_lsp.rs | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/cli/tests/integration_tests_lsp.rs b/cli/tests/integration_tests_lsp.rs index fa88ad17d..d08da622f 100644 --- a/cli/tests/integration_tests_lsp.rs +++ b/cli/tests/integration_tests_lsp.rs @@ -1604,6 +1604,74 @@ fn lsp_completions_registry_empty() { shutdown(&mut client); } +#[test] +fn lsp_diagnostics_warn() { + 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://127.0.0.1:4545/cli/tests/x_deno_warning.js\";\n\nconsole.log(a)\n", + }, + }), + ); + let (maybe_res, maybe_err) = client + .write_request::<_, _, Value>( + "deno/cache", + json!({ + "referrer": { + "uri": "file:///a/file.ts", + }, + "uris": [ + { + "uri": "http://127.0.0.1:4545/cli/tests/x_deno_warning.js", + } + ], + }), + ) + .unwrap(); + assert!(maybe_err.is_none()); + assert!(maybe_res.is_some()); + + 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, maybe_params) = client + .read_notification::<lsp::PublishDiagnosticsParams>() + .unwrap(); + assert_eq!(method, "textDocument/publishDiagnostics"); + assert_eq!( + maybe_params, + Some(lsp::PublishDiagnosticsParams { + uri: Url::parse("file:///a/file.ts").unwrap(), + diagnostics: vec![lsp::Diagnostic { + range: lsp::Range { + start: lsp::Position { + line: 0, + character: 19 + }, + end: lsp::Position { + line: 0, + character: 70 + } + }, + severity: Some(lsp::DiagnosticSeverity::Warning), + code: Some(lsp::NumberOrString::String("deno-warn".to_string())), + source: Some("deno".to_string()), + message: "foobar".to_string(), + ..Default::default() + }], + version: Some(1), + }) + ); + shutdown(&mut client); +} + #[derive(Deserialize)] #[serde(rename_all = "camelCase")] pub struct PerformanceAverage { |