summaryrefslogtreecommitdiff
path: root/test/test_code_action.vader
diff options
context:
space:
mode:
authorBartek thindil Jasicki <thindil@laeran.pl>2020-09-04 13:46:11 +0200
committerBartek thindil Jasicki <thindil@laeran.pl>2020-09-04 13:46:11 +0200
commitc78be861035765d268a5533cf583803e22d56d1c (patch)
tree63b2294216911121d594b885ae93fb82edc00273 /test/test_code_action.vader
parent0de847a8e1793b597ba0a73ae8e20797a5fce920 (diff)
parent844febb9fbfb66bb13dd652d958495e47f0bd408 (diff)
downloadale-c78be861035765d268a5533cf583803e22d56d1c.zip
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'test/test_code_action.vader')
-rw-r--r--test/test_code_action.vader46
1 files changed, 43 insertions, 3 deletions
diff --git a/test/test_code_action.vader b/test/test_code_action.vader
index b47f24ff..19de7268 100644
--- a/test/test_code_action.vader
+++ b/test/test_code_action.vader
@@ -1,4 +1,8 @@
Before:
+ Save g:ale_enabled
+
+ let g:ale_enabled = 0
+
runtime autoload/ale/code_action.vim
runtime autoload/ale/util.vim
@@ -35,6 +39,8 @@ Before:
endfunction!
After:
+ Restore
+
" Close the extra buffers if we opened it.
if bufnr(g:file1) != -1
execute ':bp! | :bd! ' . bufnr(g:file1)
@@ -50,9 +56,10 @@ After:
call delete(g:file2)
endif
- unlet g:file1
- unlet g:file2
- unlet g:test
+ unlet! g:file1
+ unlet! g:file2
+ unlet! g:test
+ unlet! g:changes
delfunction WriteFileAndEdit
runtime autoload/ale/code_action.vim
@@ -350,3 +357,36 @@ Execute(It should just modify file when should_save is set to v:false):
\ ' value: string',
\ '}',
\], getline(1, '$')
+
+Given typescript(An example TypeScript file):
+ type Foo = {}
+
+ export interface ISomething {
+ fooLongName: Foo | null
+ }
+
+ export class SomethingElse implements ISomething {
+ // Bindings
+ fooLongName!: ISomething['fooLongName']
+ }
+
+Execute():
+ let g:changes = [
+ \ {'end': {'offset': 14, 'line': 4}, 'newText': 'foo', 'start': {'offset': 3, 'line': 4}},
+ \ {'end': {'offset': 40, 'line': 9}, 'newText': 'foo', 'start': {'offset': 29, 'line': 9}},
+ \ {'end': {'offset': 14, 'line': 9}, 'newText': 'foo', 'start': {'offset': 3, 'line': 9}},
+ \]
+
+ call ale#code_action#ApplyChanges(expand('%:p'), g:changes, 0)
+
+Expect(The changes should be applied correctly):
+ type Foo = {}
+
+ export interface ISomething {
+ foo: Foo | null
+ }
+
+ export class SomethingElse implements ISomething {
+ // Bindings
+ foo!: ISomething['foo']
+ }