2017-08-29 15:05:19 +00:00
|
|
|
Before:
|
|
|
|
call ale#test#SetDirectory('/testplugin/test/fixers')
|
|
|
|
Save g:ale_javascript_prettier_executable
|
|
|
|
Save g:ale_javascript_prettier_options
|
|
|
|
|
|
|
|
" Use an invalid global executable, so we don't match it.
|
|
|
|
let g:ale_javascript_prettier_executable = 'xxxinvalid'
|
|
|
|
let g:ale_javascript_prettier_options = ''
|
|
|
|
|
|
|
|
call ale#test#SetDirectory('/testplugin/test/fixers')
|
|
|
|
silent cd ..
|
|
|
|
silent cd command_callback
|
|
|
|
let g:dir = getcwd()
|
|
|
|
|
|
|
|
After:
|
|
|
|
let g:ale_has_override = {}
|
|
|
|
call ale#test#RestoreDirectory()
|
|
|
|
|
|
|
|
Execute(The prettier callback should return the correct default values):
|
|
|
|
call ale#test#SetFilename('../prettier-test-files/testfile.js')
|
|
|
|
|
|
|
|
AssertEqual
|
|
|
|
\ {
|
|
|
|
\ 'read_temporary_file': 1,
|
|
|
|
\ 'command': ale#Escape(g:ale_javascript_prettier_executable)
|
|
|
|
\ . ' %t'
|
2017-09-06 14:21:26 +00:00
|
|
|
\ . ' --parser babylon'
|
2017-08-29 15:05:19 +00:00
|
|
|
\ . ' --write',
|
|
|
|
\ },
|
|
|
|
\ ale#fixers#prettier#Fix(bufnr(''))
|
|
|
|
|
|
|
|
Execute(The prettier callback should include configuration files when the option is set):
|
|
|
|
let g:ale_javascript_prettier_use_local_config = 1
|
|
|
|
call ale#test#SetFilename('../prettier-test-files/with_config/testfile.js')
|
|
|
|
|
|
|
|
AssertEqual
|
|
|
|
\ {
|
|
|
|
\ 'read_temporary_file': 1,
|
|
|
|
\ 'command': ale#Escape(g:ale_javascript_prettier_executable)
|
|
|
|
\ . ' %t'
|
2017-09-06 14:21:26 +00:00
|
|
|
\ . ' --parser babylon'
|
2017-10-01 19:23:41 +00:00
|
|
|
\ . ' --config ' . ale#Escape(ale#path#Winify(g:dir . '/../prettier-test-files/with_config/.prettierrc'))
|
2017-08-29 15:05:19 +00:00
|
|
|
\ . ' --write',
|
|
|
|
\ },
|
|
|
|
\ ale#fixers#prettier#Fix(bufnr(''))
|
|
|
|
|
|
|
|
Execute(The prettier callback should include custom prettier options):
|
|
|
|
let g:ale_javascript_prettier_options = '--no-semi'
|
|
|
|
call ale#test#SetFilename('../prettier-test-files/with_config/testfile.js')
|
|
|
|
|
|
|
|
AssertEqual
|
|
|
|
\ {
|
|
|
|
\ 'read_temporary_file': 1,
|
|
|
|
\ 'command': ale#Escape(g:ale_javascript_prettier_executable)
|
|
|
|
\ . ' %t'
|
2017-09-06 14:21:26 +00:00
|
|
|
\ . ' --no-semi --parser babylon'
|
2017-10-01 19:23:41 +00:00
|
|
|
\ . ' --config ' . ale#Escape(ale#path#Winify(g:dir . '/../prettier-test-files/with_config/.prettierrc'))
|
2017-08-29 15:05:19 +00:00
|
|
|
\ . ' --write',
|
|
|
|
\ },
|
|
|
|
\ ale#fixers#prettier#Fix(bufnr(''))
|
2017-09-06 14:21:26 +00:00
|
|
|
|
|
|
|
Execute(Append '--parser typescript' for filetype=typescript):
|
|
|
|
set filetype=typescript
|
|
|
|
call ale#test#SetFilename('../prettier-test-files/testfile.ts')
|
|
|
|
|
|
|
|
AssertEqual
|
|
|
|
\ {
|
|
|
|
\ 'read_temporary_file': 1,
|
|
|
|
\ 'command': ale#Escape(g:ale_javascript_prettier_executable)
|
|
|
|
\ . ' %t'
|
|
|
|
\ . ' --parser typescript'
|
|
|
|
\ . ' --write',
|
|
|
|
\ },
|
|
|
|
\ ale#fixers#prettier#Fix(bufnr(''))
|
|
|
|
|
|
|
|
Execute(Append '--parser json' for filetype=json):
|
|
|
|
set filetype=json
|
|
|
|
call ale#test#SetFilename('../prettier-test-files/testfile.json')
|
|
|
|
|
|
|
|
AssertEqual
|
|
|
|
\ {
|
|
|
|
\ 'read_temporary_file': 1,
|
|
|
|
\ 'command': ale#Escape(g:ale_javascript_prettier_executable)
|
|
|
|
\ . ' %t'
|
|
|
|
\ . ' --parser json'
|
|
|
|
\ . ' --write',
|
|
|
|
\ },
|
|
|
|
\ ale#fixers#prettier#Fix(bufnr(''))
|
|
|
|
|
|
|
|
Execute(Append '--parser postcss' for filetype=scss):
|
|
|
|
set filetype=scss
|
|
|
|
call ale#test#SetFilename('../prettier-test-files/testfile.scss')
|
|
|
|
|
|
|
|
AssertEqual
|
|
|
|
\ {
|
|
|
|
\ 'read_temporary_file': 1,
|
|
|
|
\ 'command': ale#Escape(g:ale_javascript_prettier_executable)
|
|
|
|
\ . ' %t'
|
|
|
|
\ . ' --parser postcss'
|
|
|
|
\ . ' --write',
|
|
|
|
\ },
|
|
|
|
\ ale#fixers#prettier#Fix(bufnr(''))
|
|
|
|
|
|
|
|
Execute(Append '--parser postcss' for filetype=css):
|
|
|
|
set filetype=css
|
|
|
|
call ale#test#SetFilename('../prettier-test-files/testfile.css')
|
|
|
|
|
|
|
|
AssertEqual
|
|
|
|
\ {
|
|
|
|
\ 'read_temporary_file': 1,
|
|
|
|
\ 'command': ale#Escape(g:ale_javascript_prettier_executable)
|
|
|
|
\ . ' %t'
|
|
|
|
\ . ' --parser postcss'
|
|
|
|
\ . ' --write',
|
|
|
|
\ },
|
|
|
|
\ ale#fixers#prettier#Fix(bufnr(''))
|