From 4a6136c27ec2430a1ef5481e0ca10dee03ba178f Mon Sep 17 00:00:00 2001 From: Charles B Johnson Date: Wed, 8 Apr 2020 18:20:10 -0500 Subject: [PATCH] fixers/xo: add tests --- autoload/ale/fixers/xo.vim | 4 ++- .../react-app/node_modules/xo/cli.js | 0 test/fixers/test_xo_fixer_callback.vader | 29 +++++++++++++++++++ 3 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 test/eslint-test-files/react-app/node_modules/xo/cli.js create mode 100644 test/fixers/test_xo_fixer_callback.vader diff --git a/autoload/ale/fixers/xo.vim b/autoload/ale/fixers/xo.vim index 882350be..69d23ea3 100644 --- a/autoload/ale/fixers/xo.vim +++ b/autoload/ale/fixers/xo.vim @@ -14,10 +14,12 @@ endfunction function! ale#fixers#xo#Fix(buffer) abort let l:executable = ale#fixers#xo#GetExecutable(a:buffer) + let l:options = ale#Var(a:buffer, 'javascript_xo_options') return { \ 'command': ale#node#Executable(a:buffer, l:executable) - \ . ' --fix %t', + \ . ' --fix %t' + \ . ale#Pad(l:options), \ 'read_temporary_file': 1, \} endfunction diff --git a/test/eslint-test-files/react-app/node_modules/xo/cli.js b/test/eslint-test-files/react-app/node_modules/xo/cli.js new file mode 100644 index 00000000..e69de29b diff --git a/test/fixers/test_xo_fixer_callback.vader b/test/fixers/test_xo_fixer_callback.vader new file mode 100644 index 00000000..8bccd05e --- /dev/null +++ b/test/fixers/test_xo_fixer_callback.vader @@ -0,0 +1,29 @@ +Before: + call ale#assert#SetUpFixerTest('javascript', 'xo') + +After: + call ale#assert#TearDownFixerTest() + +Execute(The xo callback should return the correct default values): + call ale#test#SetFilename('../eslint-test-files/react-app/subdir/testfile.js') + + AssertFixer + \ { + \ 'read_temporary_file': 1, + \ 'command': (has('win32') ? 'node.exe ' : '') + \ . ale#Escape(ale#path#Simplify(g:dir . '/../eslint-test-files/react-app/node_modules/xo/cli.js')) + \ . ' --fix %t', + \ } + +Execute(The xo callback should include custom xo options): + let g:ale_javascript_xo_options = '--space' + call ale#test#SetFilename('../eslint-test-files/react-app/subdir/testfile.js') + + AssertFixer + \ { + \ 'read_temporary_file': 1, + \ 'command': (has('win32') ? 'node.exe ' : '') + \ . ale#Escape(ale#path#Simplify(g:dir . '/../eslint-test-files/react-app/node_modules/xo/cli.js')) + \ . ' --fix %t' + \ . ' --space', + \ }