summaryrefslogtreecommitdiff
path: root/test/fix/test_ale_fix_suggest.vader
diff options
context:
space:
mode:
authorw0rp <devw0rp@gmail.com>2017-11-22 14:55:08 +0000
committerw0rp <devw0rp@gmail.com>2017-11-22 14:55:08 +0000
commit5ed6f66f7779bea092671521ad5743914612a18a (patch)
tree6776c7feb9da725c2a7669d58748b0ed849021a2 /test/fix/test_ale_fix_suggest.vader
parent4b4762697c03e3b82b032d442289deaac9bd38e6 (diff)
downloadale-5ed6f66f7779bea092671521ad5743914612a18a.zip
Reorganise the ALEFix tests
Diffstat (limited to 'test/fix/test_ale_fix_suggest.vader')
-rw-r--r--test/fix/test_ale_fix_suggest.vader102
1 files changed, 102 insertions, 0 deletions
diff --git a/test/fix/test_ale_fix_suggest.vader b/test/fix/test_ale_fix_suggest.vader
new file mode 100644
index 00000000..97227b4f
--- /dev/null
+++ b/test/fix/test_ale_fix_suggest.vader
@@ -0,0 +1,102 @@
+Before:
+ call ale#fix#registry#Clear()
+
+ let g:buffer = bufnr('')
+
+ function GetSuggestions()
+ silent ALEFixSuggest
+
+ if bufnr('') != g:buffer
+ let l:lines = getline(1, '$')
+ else
+ let l:lines = []
+ endif
+
+ return l:lines
+ endfunction
+
+After:
+ if bufnr('') != g:buffer
+ :q!
+ endif
+
+ unlet! g:buffer
+
+ call ale#fix#registry#ResetToDefaults()
+ delfunction GetSuggestions
+
+Execute(ALEFixSuggest should return something sensible with no suggestions):
+ AssertEqual
+ \ [
+ \ 'There is nothing in the registry to suggest.',
+ \ '',
+ \ 'Press q to close this window',
+ \ ],
+ \ GetSuggestions()
+
+Execute(ALEFixSuggest should set the appropriate settings):
+ silent ALEFixSuggest
+
+ AssertEqual 'ale-fix-suggest', &filetype
+ Assert !&modified, 'The buffer was marked as modified'
+ Assert !&modifiable, 'The buffer was modifiable'
+
+Execute(ALEFixSuggest output should be correct for only generic handlers):
+ call ale#fix#registry#Add('zed', 'XYZ', [], 'Zedify things.')
+ call ale#fix#registry#Add('alpha', 'XYZ', [], 'Alpha things.')
+
+ AssertEqual
+ \ [
+ \ 'Try the following generic fixers:',
+ \ '',
+ \ '''alpha'' - Alpha things.',
+ \ '''zed'' - Zedify things.',
+ \ '',
+ \ 'See :help ale-fix-configuration',
+ \ '',
+ \ 'Press q to close this window',
+ \ ],
+ \ GetSuggestions()
+
+Execute(ALEFixSuggest output should be correct for only filetype handlers):
+ let &filetype = 'testft2.testft'
+
+ call ale#fix#registry#Add('zed', 'XYZ', ['testft2'], 'Zedify things.')
+ call ale#fix#registry#Add('alpha', 'XYZ', ['testft'], 'Alpha things.')
+
+ AssertEqual
+ \ [
+ \ 'Try the following fixers appropriate for the filetype:',
+ \ '',
+ \ '''alpha'' - Alpha things.',
+ \ '''zed'' - Zedify things.',
+ \ '',
+ \ 'See :help ale-fix-configuration',
+ \ '',
+ \ 'Press q to close this window',
+ \ ],
+ \ GetSuggestions()
+
+Execute(ALEFixSuggest should suggest filetype and generic handlers):
+ let &filetype = 'testft2.testft'
+
+ call ale#fix#registry#Add('zed', 'XYZ', ['testft2'], 'Zedify things.')
+ call ale#fix#registry#Add('alpha', 'XYZ', ['testft'], 'Alpha things.')
+ call ale#fix#registry#Add('generic', 'XYZ', [], 'Generic things.')
+
+ AssertEqual
+ \ [
+ \ 'Try the following fixers appropriate for the filetype:',
+ \ '',
+ \ '''alpha'' - Alpha things.',
+ \ '''zed'' - Zedify things.',
+ \ '',
+ \ 'Try the following generic fixers:',
+ \ '',
+ \ '''generic'' - Generic things.',
+ \ '',
+ \ 'See :help ale-fix-configuration',
+ \ '',
+ \ 'Press q to close this window',
+ \ ],
+ \ GetSuggestions()