From 4b6691f602e8574fb41b8e63d8d95f7c0ecbb878 Mon Sep 17 00:00:00 2001 From: harttle Date: Thu, 11 Apr 2019 19:47:31 +0800 Subject: [PATCH] test: unit test for fecs fixer, fecs command --- test/command_callback/fecs_paths/fecs | 0 test/command_callback/fecs_paths/fecs.exe | 0 .../test_fecs_command_callback.vader | 8 ++++++ test/fixers/test_fecs_fixer_callback.vader | 26 +++++++++++++++++++ 4 files changed, 34 insertions(+) create mode 100755 test/command_callback/fecs_paths/fecs create mode 100755 test/command_callback/fecs_paths/fecs.exe create mode 100644 test/command_callback/test_fecs_command_callback.vader create mode 100644 test/fixers/test_fecs_fixer_callback.vader diff --git a/test/command_callback/fecs_paths/fecs b/test/command_callback/fecs_paths/fecs new file mode 100755 index 00000000..e69de29b diff --git a/test/command_callback/fecs_paths/fecs.exe b/test/command_callback/fecs_paths/fecs.exe new file mode 100755 index 00000000..e69de29b diff --git a/test/command_callback/test_fecs_command_callback.vader b/test/command_callback/test_fecs_command_callback.vader new file mode 100644 index 00000000..f70ad084 --- /dev/null +++ b/test/command_callback/test_fecs_command_callback.vader @@ -0,0 +1,8 @@ +Before: + call ale#assert#SetUpLinterTest('javascript', 'fecs') + +After: + call ale#assert#TearDownLinterTest() + +Execute(The default command should be correct): + AssertLinter 'fecs', ale#Escape('fecs') . ' check --colors=false --rule=true %t' diff --git a/test/fixers/test_fecs_fixer_callback.vader b/test/fixers/test_fecs_fixer_callback.vader new file mode 100644 index 00000000..809b4d46 --- /dev/null +++ b/test/fixers/test_fecs_fixer_callback.vader @@ -0,0 +1,26 @@ +Before: + call ale#assert#SetUpFixerTest('javascript', 'fecs') + runtime autoload/ale/handlers/fecs.vim + +After: + call ale#assert#TearDownFixerTest() + +Execute(The fecs fixer should respect to g:ale_javascript_fecs_executable): + let g:ale_javascript_fecs_executable = 'fecs_paths/fecs' + let g:ale_javascript_fecs_use_global = 1 + silent cd ../command_callback + let g:dir = getcwd() + + AssertEqual + \ { + \ 'command': ale#Escape(g:ale_javascript_fecs_executable) . ' format --replace=true %t', + \ 'read_temporary_file': 1, + \ }, + \ ale#fixers#fecs#Fix(bufnr('')) + +Execute(The fecs fixer should return 0 when executable not found): + let g:ale_javascript_fecs_executable = 'fecs-invalid' + let g:ale_javascript_fecs_use_global = 1 + AssertEqual + \ 0, + \ ale#fixers#fecs#Fix(bufnr(''))