Support fixing JSON files with fixjson
This commit is contained in:
parent
d562d53102
commit
b28a6ddbe4
7 changed files with 118 additions and 2 deletions
50
test/fixers/test_fixjson_fixer_callback.vader
Normal file
50
test/fixers/test_fixjson_fixer_callback.vader
Normal file
|
@ -0,0 +1,50 @@
|
|||
Before:
|
||||
Save g:ale_json_fixjson_executable
|
||||
Save g:ale_json_fixjson_options
|
||||
|
||||
let g:ale_json_fixjson_executable = '/path/to/fixjson'
|
||||
let g:ale_json_fixjson_options = ''
|
||||
|
||||
call ale#test#SetDirectory('/testplugin/test/fixers')
|
||||
|
||||
After:
|
||||
Restore
|
||||
|
||||
Execute(The fixjson callback should return the correct default command):
|
||||
AssertEqual
|
||||
\ {
|
||||
\ 'command': ale#Escape('/path/to/fixjson')
|
||||
\ . ' --stdin-filename '
|
||||
\ . ale#Escape(bufname(bufnr('')))
|
||||
\ },
|
||||
\ ale#fixers#fixjson#Fix(bufnr(''))
|
||||
|
||||
Execute(The fixjson callback should set the buffer name as file name):
|
||||
call ale#test#SetFilename('../json_files/testfile.json')
|
||||
|
||||
AssertEqual
|
||||
\ {
|
||||
\ 'command': ale#Escape('/path/to/fixjson')
|
||||
\ . ' --stdin-filename '
|
||||
\ . ale#Escape(bufname(bufnr('')))
|
||||
\ },
|
||||
\ ale#fixers#fixjson#Fix(bufnr(''))
|
||||
|
||||
AssertNotEqual
|
||||
\ stridx(
|
||||
\ ale#fixers#fixjson#Fix(bufnr('')).command,
|
||||
\ 'testfile.json',
|
||||
\ ),
|
||||
\ -1
|
||||
|
||||
Execute(The fixjson callback should include additional options):
|
||||
let g:ale_json_fixjson_options = '-i 2'
|
||||
|
||||
AssertEqual
|
||||
\ {
|
||||
\ 'command': ale#Escape('/path/to/fixjson')
|
||||
\ . ' --stdin-filename '
|
||||
\ . ale#Escape(bufname(bufnr('')))
|
||||
\ . ' -i 2'
|
||||
\ },
|
||||
\ ale#fixers#fixjson#Fix(bufnr(''))
|
1
test/json_files/testfile.json
Normal file
1
test/json_files/testfile.json
Normal file
|
@ -0,0 +1 @@
|
|||
{"answer":42}
|
Loading…
Add table
Add a link
Reference in a new issue