diff options
author | w0rp <devw0rp@gmail.com> | 2020-09-04 09:37:33 +0100 |
---|---|---|
committer | w0rp <devw0rp@gmail.com> | 2020-09-04 09:37:33 +0100 |
commit | 844febb9fbfb66bb13dd652d958495e47f0bd408 (patch) | |
tree | 69781eefef1c9cc9cc410fee5e21a50bb56a35f8 /test/test_code_action.vader | |
parent | d4a14746cdcda99ec70915c5540962c85e33f661 (diff) | |
download | ale-844febb9fbfb66bb13dd652d958495e47f0bd408.zip |
Fix #3322 - Apply rename changes correctly
Diffstat (limited to 'test/test_code_action.vader')
-rw-r--r-- | test/test_code_action.vader | 46 |
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'] + } |