summaryrefslogtreecommitdiff
path: root/tests/integration
diff options
context:
space:
mode:
Diffstat (limited to 'tests/integration')
-rw-r--r--tests/integration/lsp_tests.rs98
1 files changed, 98 insertions, 0 deletions
diff --git a/tests/integration/lsp_tests.rs b/tests/integration/lsp_tests.rs
index 09178cd46..c5913e07b 100644
--- a/tests/integration/lsp_tests.rs
+++ b/tests/integration/lsp_tests.rs
@@ -10198,6 +10198,104 @@ console.log(snake_case);
}
#[test]
+fn lsp_code_actions_lint_fixes() {
+ let context = TestContextBuilder::new().use_temp_cwd().build();
+ let mut client = context.new_lsp_command().build();
+ client.initialize_default();
+ let diagnostics = client.did_open(json!({
+ "textDocument": {
+ "uri": "file:///a/file.ts",
+ "languageId": "typescript",
+ "version": 1,
+ "text": "window;",
+ }
+ }));
+ let diagnostics = diagnostics.all();
+ let diagnostic = &diagnostics[0];
+ let res = client.write_request(
+ "textDocument/codeAction",
+ json!({
+ "textDocument": {
+ "uri": "file:///a/file.ts"
+ },
+ "range": {
+ "start": { "line": 0, "character": 0 },
+ "end": { "line": 0, "character": 6 }
+ },
+ "context": {
+ "diagnostics": [diagnostic],
+ "only": ["quickfix"]
+ }
+ }),
+ );
+ assert_eq!(
+ res,
+ json!([{
+ "title": "Rename window to globalThis",
+ "kind": "quickfix",
+ "diagnostics": [diagnostic],
+ "edit": {
+ "changes": {
+ "file:///a/file.ts": [{
+ "range": {
+ "start": { "line": 0, "character": 0 },
+ "end": { "line": 0, "character": 6 }
+ },
+ "newText": "globalThis"
+ }]
+ }
+ }
+ }, {
+ "title": "Disable no-window for this line",
+ "kind": "quickfix",
+ "diagnostics": [diagnostic],
+ "edit": {
+ "changes": {
+ "file:///a/file.ts": [{
+ "range": {
+ "start": { "line": 0, "character": 0 },
+ "end": { "line": 0, "character": 0 }
+ },
+ "newText": "// deno-lint-ignore no-window\n"
+ }]
+ }
+ }
+ }, {
+ "title": "Disable no-window for the entire file",
+ "kind": "quickfix",
+ "diagnostics": [diagnostic],
+ "edit": {
+ "changes": {
+ "file:///a/file.ts": [{
+ "range": {
+ "start": { "line": 0, "character": 0 },
+ "end": { "line": 0, "character": 0 }
+ },
+ "newText": "// deno-lint-ignore-file no-window\n"
+ }]
+ }
+ }
+ }, {
+ "title": "Ignore lint errors for the entire file",
+ "kind": "quickfix",
+ "diagnostics": [diagnostic],
+ "edit": {
+ "changes": {
+ "file:///a/file.ts": [{
+ "range": {
+ "start": { "line": 0, "character": 0 },
+ "end": { "line": 0, "character": 0 }
+ },
+ "newText": "// deno-lint-ignore-file\n"
+ }]
+ }
+ }
+ }])
+ );
+ client.shutdown();
+}
+
+#[test]
fn lsp_lint_with_config() {
let context = TestContextBuilder::new().use_temp_cwd().build();
let temp_dir = context.temp_dir();