diff options
author | D. Ben Knoble <ben.knoble+github@gmail.com> | 2020-11-30 13:42:21 -0500 |
---|---|---|
committer | D. Ben Knoble <ben.knoble+github@gmail.com> | 2020-11-30 13:42:21 -0500 |
commit | 7e12be0c643857221fb0772ffceba9ff4cd66cc9 (patch) | |
tree | 2db8c638bc9e8d1c68e1751a48888918e4bd9e4e /test/test_code_action.vader | |
parent | 47da7483d8d4bbbe4022b9c0821d3a7d2d0afaaf (diff) | |
parent | 03b6978a270107b670b0363d50f3eed4b365ba26 (diff) | |
download | ale-7e12be0c643857221fb0772ffceba9ff4cd66cc9.zip |
Merge remote-tracking branch 'origin/master' into fix-swipl
* origin/master: (40 commits)
fix: correct suggested filetype for yamlfix
feat: add yamlfix fixer
Use _config for LSP config options
Add support for R languageserver (#3370)
Fix 3103 - add shellcheck shell directive detection. (#3216)
Added the Vundle command in installation instructions (#3400)
Adds support for Tlint - A Tighten Opinionated PHP Linter (#3291)
Add php phpcbf options (#3383)
Use has('gui_running') instead of has('gui')
Close #2727 - Add a hover-only setting for balloons
Fix #3332 - Modify everything for rename/actions
Add a missing blank line in documentation
Add luafmt fixer (#3289)
#3442 Fix code fix clangd issue
Close #1466 - Add GVIM refactor menu support
Look for node packages in .yarn/sdks as well
Update documentation for code actions and rename
cmp forwards, and reverse the code actions
Support for LSP/tsserver Code Actions (#3437)
Move the test for buffer-local variables
...
Diffstat (limited to 'test/test_code_action.vader')
-rw-r--r-- | test/test_code_action.vader | 80 |
1 files changed, 49 insertions, 31 deletions
diff --git a/test/test_code_action.vader b/test/test_code_action.vader index 19de7268..7eabb759 100644 --- a/test/test_code_action.vader +++ b/test/test_code_action.vader @@ -3,6 +3,9 @@ Before: let g:ale_enabled = 0 + " Enable fix end-of-line as tests below expect that + set fixeol + runtime autoload/ale/code_action.vim runtime autoload/ale/util.vim @@ -85,7 +88,8 @@ Execute(It should modify and save multiple files): \ 'import D from "D"', \], g:file2, 'S') - call ale#code_action#HandleCodeAction({ + call ale#code_action#HandleCodeAction( + \ { \ 'changes': [{ \ 'fileName': g:file1, \ 'textChanges': [{ @@ -122,8 +126,10 @@ Execute(It should modify and save multiple files): \ }, \ 'newText': "import {A, B} from 'module'\n\n", \ }] - \ }], - \}, v:true) + \ }], + \ }, + \ {'should_save': 1}, + \) AssertEqual [ \ 'class Value {', @@ -153,7 +159,8 @@ Execute(Beginning of file can be modified): \] call writefile(g:test.text, g:file1, 'S') - call ale#code_action#HandleCodeAction({ + call ale#code_action#HandleCodeAction( + \ { \ 'changes': [{ \ 'fileName': g:file1, \ 'textChanges': [{ @@ -168,7 +175,9 @@ Execute(Beginning of file can be modified): \ 'newText': "type A: string\ntype B: number\n", \ }], \ }] - \}, v:true) + \ }, + \ {'should_save': 1}, + \) AssertEqual [ \ 'type A: string', @@ -184,24 +193,28 @@ Execute(End of file can be modified): \] call writefile(g:test.text, g:file1, 'S') - call ale#code_action#HandleCodeAction({ + call ale#code_action#HandleCodeAction( + \ { \ 'changes': [{ - \ 'fileName': g:file1, - \ 'textChanges': [{ - \ 'start': { - \ 'line': 4, - \ 'offset': 1, - \ }, - \ 'end': { - \ 'line': 4, - \ 'offset': 1, - \ }, - \ 'newText': "type A: string\ntype B: number\n", - \ }], + \ 'fileName': g:file1, + \ 'textChanges': [{ + \ 'start': { + \ 'line': 4, + \ 'offset': 1, + \ }, + \ 'end': { + \ 'line': 4, + \ 'offset': 1, + \ }, + \ 'newText': "type A: string\ntype B: number\n", + \ }], \ }] - \}, v:true) + \ }, + \ {'should_save': 1}, + \) AssertEqual g:test.text + [ + \ '', \ 'type A: string', \ 'type B: number', \ '', @@ -219,7 +232,8 @@ Execute(Current buffer contents will be reloaded): execute 'edit ' . g:file1 let g:test.buffer = bufnr(g:file1) - call ale#code_action#HandleCodeAction({ + call ale#code_action#HandleCodeAction( + \ { \ 'changes': [{ \ 'fileName': g:file1, \ 'textChanges': [{ @@ -234,7 +248,9 @@ Execute(Current buffer contents will be reloaded): \ 'newText': "type A: string\ntype B: number\n", \ }], \ }] - \}, v:true) + \ }, + \ {'should_save': 1}, + \) AssertEqual [ \ 'type A: string', @@ -256,11 +272,11 @@ Execute(Cursor will not move when it is before text change): let g:test.changes = g:test.create_change(2, 3, 2, 8, 'value2') call setpos('.', [0, 1, 1, 0]) - call ale#code_action#HandleCodeAction(g:test.changes, v:true) + call ale#code_action#HandleCodeAction(g:test.changes, {'should_save': 1}) AssertEqual [1, 1], getpos('.')[1:2] call setpos('.', [0, 2, 2, 0]) - call ale#code_action#HandleCodeAction(g:test.changes, v:true) + call ale#code_action#HandleCodeAction(g:test.changes, {'should_save': 1}) AssertEqual [2, 2], getpos('.')[1:2] # ====C==== @@ -271,7 +287,7 @@ Execute(Cursor column will move to the change end when cursor between start/end) call WriteFileAndEdit() call setpos('.', [0, 2, r, 0]) AssertEqual ' value: string', getline('.') - call ale#code_action#HandleCodeAction(g:test.changes, v:true) + call ale#code_action#HandleCodeAction(g:test.changes, {'should_save': 1}) AssertEqual ' value2: string', getline('.') AssertEqual [2, 9], getpos('.')[1:2] endfor @@ -283,7 +299,9 @@ Execute(Cursor column will move back when new text is shorter): call setpos('.', [0, 2, 8, 0]) AssertEqual ' value: string', getline('.') call ale#code_action#HandleCodeAction( - \ g:test.create_change(2, 3, 2, 8, 'val'), v:true) + \ g:test.create_change(2, 3, 2, 8, 'val'), + \ {'should_save': 1}, + \) AssertEqual ' val: string', getline('.') AssertEqual [2, 6], getpos('.')[1:2] @@ -295,7 +313,7 @@ Execute(Cursor column will move forward when new text is longer): call setpos('.', [0, 2, 8, 0]) AssertEqual ' value: string', getline('.') call ale#code_action#HandleCodeAction( - \ g:test.create_change(2, 3, 2, 8, 'longValue'), v:true) + \ g:test.create_change(2, 3, 2, 8, 'longValue'), {'should_save': 1}) AssertEqual ' longValue: string', getline('.') AssertEqual [2, 12], getpos('.')[1:2] @@ -307,7 +325,7 @@ Execute(Cursor line will move when updates are happening on lines above): call setpos('.', [0, 3, 1, 0]) AssertEqual '}', getline('.') call ale#code_action#HandleCodeAction( - \ g:test.create_change(1, 1, 2, 1, "test\ntest\n"), v:true) + \ g:test.create_change(1, 1, 2, 1, "test\ntest\n"), {'should_save': 1}) AssertEqual '}', getline('.') AssertEqual [4, 1], getpos('.')[1:2] @@ -319,7 +337,7 @@ Execute(Cursor line and column will move when change on lines above and just bef call setpos('.', [0, 2, 2, 0]) AssertEqual ' value: string', getline('.') call ale#code_action#HandleCodeAction( - \ g:test.create_change(1, 1, 2, 1, "test\ntest\n123"), v:true) + \ g:test.create_change(1, 1, 2, 1, "test\ntest\n123"), {'should_save': 1}) AssertEqual '123 value: string', getline('.') AssertEqual [3, 5], getpos('.')[1:2] @@ -331,7 +349,7 @@ Execute(Cursor line and column will move at the end of changes): call setpos('.', [0, 2, 10, 0]) AssertEqual ' value: string', getline('.') call ale#code_action#HandleCodeAction( - \ g:test.create_change(1, 1, 3, 1, "test\n"), v:true) + \ g:test.create_change(1, 1, 3, 1, "test\n"), {'should_save': 1}) AssertEqual '}', getline('.') AssertEqual [2, 1], getpos('.')[1:2] @@ -342,14 +360,14 @@ Execute(Cursor will not move when changes happening on lines >= cursor, but afte call setpos('.', [0, 2, 3, 0]) AssertEqual ' value: string', getline('.') call ale#code_action#HandleCodeAction( - \ g:test.create_change(2, 10, 3, 1, "number\n"), v:true) + \ g:test.create_change(2, 10, 3, 1, "number\n"), {'should_save': 1}) AssertEqual ' value: number', getline('.') AssertEqual [2, 3], getpos('.')[1:2] Execute(It should just modify file when should_save is set to v:false): call WriteFileAndEdit() let g:test.change = g:test.create_change(1, 1, 1, 1, "import { writeFile } from 'fs';\n") - call ale#code_action#HandleCodeAction(g:test.change, v:false) + call ale#code_action#HandleCodeAction(g:test.change, {}) AssertEqual 1, getbufvar(bufnr(''), '&modified') AssertEqual [ \ 'import { writeFile } from ''fs'';', |