summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authortaylorskalyo <taylorskalyo@users.noreply.github.com>2017-03-30 18:21:37 -0400
committerw0rp <w0rp@users.noreply.github.com>2017-03-30 23:21:37 +0100
commit36f9631512fe164ae115c4a216d3cddbf81e6daa (patch)
tree053e4741faeb285bf34d880a539c803f789f67ee /test
parent3a74d242f9b2b09dd066e5cfd6ed9a0149395b87 (diff)
downloadale-36f9631512fe164ae115c4a216d3cddbf81e6daa.zip
Add options to facilitate linting only in normal mode (#425)
* [#420] Add options to facilitate linting only in normal mode ale_lint_on_text_changed: Allow setting to 'insert' or 'normal' to lint when text is changed only in insert or normal mode respectively. ale_lint_on_insert_leave: This flag can be set to 1 to enable linting when leaving insert mode. * [#420] Test updated global options Ale should - bind to TextChanged events when g:ale_lint_on_text_changed = 1 - bind to TextChanged events when g:ale_lint_on_text_changed = 'always' - bind to InsertLeave event when g:ale_lint_on_insert_leave = 1
Diffstat (limited to 'test')
-rw-r--r--test/test_ale_info.vader2
-rw-r--r--test/test_ale_init_au_groups.vader66
2 files changed, 67 insertions, 1 deletions
diff --git a/test/test_ale_info.vader b/test/test_ale_info.vader
index 6dd6afee..d5a8ed62 100644
--- a/test/test_ale_info.vader
+++ b/test/test_ale_info.vader
@@ -19,7 +19,7 @@ Before:
\ 'let g:ale_lint_delay = 200',
\ 'let g:ale_lint_on_enter = 1',
\ 'let g:ale_lint_on_save = 1',
- \ 'let g:ale_lint_on_text_changed = 1',
+ \ 'let g:ale_lint_on_text_changed = ''always''',
\ 'let g:ale_linter_aliases = {}',
\ 'let g:ale_linters = {}',
\ 'let g:ale_open_list = 0',
diff --git a/test/test_ale_init_au_groups.vader b/test/test_ale_init_au_groups.vader
new file mode 100644
index 00000000..bcefabe1
--- /dev/null
+++ b/test/test_ale_init_au_groups.vader
@@ -0,0 +1,66 @@
+Before:
+ Save g:ale_lint_on_text_changed
+ Save g:ale_lint_on_insert_leave
+ autocmd!
+
+After:
+ Restore g:ale_lint_on_text_changed
+ Restore g:ale_lint_on_insert_leave
+ unlet! g:output
+ unlet! g:expected_autocmd
+ autocmd!
+
+Execute (ALE should bind to TextChanged events when g:ale_lint_on_text_changed = 1):
+ let g:expected_autocmd = join([
+ \ '',
+ \ '--- Auto-Commands ---',
+ \ 'ALERunOnTextChangedGroup TextChanged',
+ \ ' * call ale#Queue(g:ale_lint_delay)',
+ \ 'ALERunOnTextChangedGroup TextChangedI',
+ \ ' * call ale#Queue(g:ale_lint_delay)',
+ \], "\n")
+
+ let g:ale_lint_on_text_changed = 1
+ call ALEInitAuGroups()
+
+ redir => g:output
+ autocmd ALERunOnTextChangedGroup TextChanged,TextChangedI *
+ redir END
+
+ AssertEqual g:expected_autocmd, g:output
+
+Execute (ALE should bind to TextChanged events when g:ale_lint_on_text_changed = 'always'):
+ let g:expected_autocmd = join([
+ \ '',
+ \ '--- Auto-Commands ---',
+ \ 'ALERunOnTextChangedGroup TextChanged',
+ \ ' * call ale#Queue(g:ale_lint_delay)',
+ \ 'ALERunOnTextChangedGroup TextChangedI',
+ \ ' * call ale#Queue(g:ale_lint_delay)',
+ \], "\n")
+
+ let g:ale_lint_on_text_changed = 'always'
+ call ALEInitAuGroups()
+
+ redir => g:output
+ autocmd ALERunOnTextChangedGroup TextChanged,TextChangedI *
+ redir END
+
+ AssertEqual g:expected_autocmd, g:output
+
+Execute (ALE should bind to InsertLeave event when g:ale_lint_on_insert_leave = 1):
+ let g:expected_autocmd = join([
+ \ "",
+ \ "--- Auto-Commands ---",
+ \ "ALERunOnInsertLeave InsertLeave",
+ \ " * call ale#Queue(0, 'lint_file')",
+ \], "\n")
+
+ let g:ale_lint_on_insert_leave = 1
+ call ALEInitAuGroups()
+
+ redir => g:output
+ autocmd ALERunOnInsertLeave InsertLeave *
+ redir END
+
+ AssertEqual g:expected_autocmd, g:output