diff options
author | aliou <aliou@users.noreply.github.com> | 2017-08-29 17:05:19 +0200 |
---|---|---|
committer | w0rp <w0rp@users.noreply.github.com> | 2017-08-29 16:05:19 +0100 |
commit | b36882e72e14673a62bcc129f00e58caa5f0c9d3 (patch) | |
tree | 2f2d2324c95de9f6b016bf4d164a0e31d8293ed2 /test/fixers | |
parent | 87fb72346ac2353000c987cbc24326301d95a343 (diff) | |
download | ale-b36882e72e14673a62bcc129f00e58caa5f0c9d3.zip |
Add support for prettier configuration file. (#886)
* Add support for prettier configuration file.
As of version 1.6.0, prettier allows passing a `--config` argument with
a path to a configuration file.
* Add test prettier configuration file.
* Add option to use local prettier configuration.
* Add description for new prettier option.
* Also check if the config is present before using it.
Diffstat (limited to 'test/fixers')
-rw-r--r-- | test/fixers/test_prettier_fixer_callback.vader | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/test/fixers/test_prettier_fixer_callback.vader b/test/fixers/test_prettier_fixer_callback.vader new file mode 100644 index 00000000..1eb24dae --- /dev/null +++ b/test/fixers/test_prettier_fixer_callback.vader @@ -0,0 +1,58 @@ +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' + \ . ' --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' + \ . ' --config ' . ale#Escape(simplify(g:dir . '/../prettier-test-files/with_config/.prettierrc')) + \ . ' --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' + \ . ' --no-semi' + \ . ' --config ' . ale#Escape(simplify(g:dir . '/../prettier-test-files/with_config/.prettierrc')) + \ . ' --write', + \ }, + \ ale#fixers#prettier#Fix(bufnr('')) |