summaryrefslogtreecommitdiff
path: root/test/test_code_action.vader
diff options
context:
space:
mode:
authorJerko Steiner <jerko.steiner@gmail.com>2019-10-09 20:42:41 -0500
committerJerko Steiner <jerko.steiner@gmail.com>2019-10-09 20:54:47 -0500
commitc8c142b8812701eddab7b7fef10cfff0c44e2a64 (patch)
treecb8aba7a31f717a2749a4a99b5243e3d96e38430 /test/test_code_action.vader
parent3fe2223a48465c58c48a5a6a30ecf13ab92f7b97 (diff)
downloadale-c8c142b8812701eddab7b7fef10cfff0c44e2a64.zip
Do not save for ALERename and ALEOrganizeImports
Diffstat (limited to 'test/test_code_action.vader')
-rw-r--r--test/test_code_action.vader48
1 files changed, 33 insertions, 15 deletions
diff --git a/test/test_code_action.vader b/test/test_code_action.vader
index ffaca630..b47f24ff 100644
--- a/test/test_code_action.vader
+++ b/test/test_code_action.vader
@@ -37,10 +37,10 @@ Before:
After:
" Close the extra buffers if we opened it.
if bufnr(g:file1) != -1
- execute ':bp | :bd ' . bufnr(g:file1)
+ execute ':bp! | :bd! ' . bufnr(g:file1)
endif
if bufnr(g:file2) != -1
- execute ':bp | :bd ' . bufnr(g:file2)
+ execute ':bp! | :bd! ' . bufnr(g:file2)
endif
if filereadable(g:file1)
@@ -116,7 +116,7 @@ Execute(It should modify and save multiple files):
\ 'newText': "import {A, B} from 'module'\n\n",
\ }]
\ }],
- \})
+ \}, v:true)
AssertEqual [
\ 'class Value {',
@@ -161,7 +161,7 @@ Execute(Beginning of file can be modified):
\ 'newText': "type A: string\ntype B: number\n",
\ }],
\ }]
- \})
+ \}, v:true)
AssertEqual [
\ 'type A: string',
@@ -192,7 +192,7 @@ Execute(End of file can be modified):
\ 'newText': "type A: string\ntype B: number\n",
\ }],
\ }]
- \})
+ \}, v:true)
AssertEqual g:test.text + [
\ 'type A: string',
@@ -227,7 +227,7 @@ Execute(Current buffer contents will be reloaded):
\ 'newText': "type A: string\ntype B: number\n",
\ }],
\ }]
- \})
+ \}, v:true)
AssertEqual [
\ 'type A: string',
@@ -249,11 +249,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)
+ call ale#code_action#HandleCodeAction(g:test.changes, v:true)
AssertEqual [1, 1], getpos('.')[1:2]
call setpos('.', [0, 2, 2, 0])
- call ale#code_action#HandleCodeAction(g:test.changes)
+ call ale#code_action#HandleCodeAction(g:test.changes, v:true)
AssertEqual [2, 2], getpos('.')[1:2]
# ====C====
@@ -264,7 +264,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)
+ call ale#code_action#HandleCodeAction(g:test.changes, v:true)
AssertEqual ' value2: string', getline('.')
AssertEqual [2, 9], getpos('.')[1:2]
endfor
@@ -275,7 +275,8 @@ Execute(Cursor column will move back when new text is shorter):
call WriteFileAndEdit()
call setpos('.', [0, 2, 8, 0])
AssertEqual ' value: string', getline('.')
- call ale#code_action#HandleCodeAction(g:test.create_change(2, 3, 2, 8, 'val'))
+ call ale#code_action#HandleCodeAction(
+ \ g:test.create_change(2, 3, 2, 8, 'val'), v:true)
AssertEqual ' val: string', getline('.')
AssertEqual [2, 6], getpos('.')[1:2]
@@ -286,7 +287,8 @@ 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'))
+ call ale#code_action#HandleCodeAction(
+ \ g:test.create_change(2, 3, 2, 8, 'longValue'), v:true)
AssertEqual ' longValue: string', getline('.')
AssertEqual [2, 12], getpos('.')[1:2]
@@ -297,7 +299,8 @@ Execute(Cursor line will move when updates are happening on lines above):
call WriteFileAndEdit()
call setpos('.', [0, 3, 1, 0])
AssertEqual '}', getline('.')
- call ale#code_action#HandleCodeAction(g:test.create_change(1, 1, 2, 1, "test\ntest\n"))
+ call ale#code_action#HandleCodeAction(
+ \ g:test.create_change(1, 1, 2, 1, "test\ntest\n"), v:true)
AssertEqual '}', getline('.')
AssertEqual [4, 1], getpos('.')[1:2]
@@ -308,7 +311,8 @@ Execute(Cursor line and column will move when change on lines above and just bef
call WriteFileAndEdit()
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"))
+ call ale#code_action#HandleCodeAction(
+ \ g:test.create_change(1, 1, 2, 1, "test\ntest\n123"), v:true)
AssertEqual '123 value: string', getline('.')
AssertEqual [3, 5], getpos('.')[1:2]
@@ -319,7 +323,8 @@ Execute(Cursor line and column will move at the end of changes):
call WriteFileAndEdit()
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"))
+ call ale#code_action#HandleCodeAction(
+ \ g:test.create_change(1, 1, 3, 1, "test\n"), v:true)
AssertEqual '}', getline('.')
AssertEqual [2, 1], getpos('.')[1:2]
@@ -329,6 +334,19 @@ Execute(Cursor will not move when changes happening on lines >= cursor, but afte
call WriteFileAndEdit()
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"))
+ call ale#code_action#HandleCodeAction(
+ \ g:test.create_change(2, 10, 3, 1, "number\n"), v:true)
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)
+ AssertEqual 1, getbufvar(bufnr(''), '&modified')
+ AssertEqual [
+ \ 'import { writeFile } from ''fs'';',
+ \ 'class Name {',
+ \ ' value: string',
+ \ '}',
+ \], getline(1, '$')