]> git.madduck.net Git - etc/vim.git/blobdiff - .vim/bundle/ale/test/test_floating_preview.vader

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Merge commit '76265755a1add77121c8f9dabb3e9bb70fe9a972' as '.vim/bundle/ale'
[etc/vim.git] / .vim / bundle / ale / test / test_floating_preview.vader
diff --git a/.vim/bundle/ale/test/test_floating_preview.vader b/.vim/bundle/ale/test/test_floating_preview.vader
new file mode 100644 (file)
index 0000000..f765f3f
--- /dev/null
@@ -0,0 +1,93 @@
+Before:
+  let g:ale_floating_preview = 0
+  let g:ale_hover_to_floating_preview = 0
+  let g:ale_detail_to_floating_preview = 0
+
+  runtime autoload/ale/floating_preview.vim
+
+  let g:floated_lines = []
+  let g:floating_preview_show_called = 0
+
+  " Stub out so we can track the call
+  function! ale#floating_preview#Show(lines, ...) abort
+    let g:floating_preview_show_called = 1
+    let g:floated_lines = a:lines
+    return win_getid()
+  endfunction
+
+  let g:ale_buffer_info = {
+  \ bufnr('%'): {
+  \   'loclist': [
+  \     {
+  \       'lnum': 1,
+  \       'col': 10,
+  \       'bufnr': bufnr('%'),
+  \       'vcol': 0,
+  \       'linter_name': 'notalinter',
+  \       'nr': -1,
+  \       'type': 'E',
+  \       'code': 'semi',
+  \       'text': "Missing semicolon.\r",
+  \       'detail': "Every statement should end with a semicolon\nsecond line",
+  \     },
+  \   ],
+  \ }
+  \}
+
+  call ale#linter#Reset()
+  call ale#linter#PreventLoading('javascript')
+
+After:
+  Restore
+
+  let g:ale_floating_preview = 0
+  let g:ale_hover_to_floating_preview = 0
+  let g:ale_detail_to_floating_preview = 0
+
+  call cursor(1, 1)
+
+  let g:ale_buffer_info = {}
+
+  " Close the preview window if it's open.
+  if &filetype is# 'ale-preview'
+    noautocmd :q!
+  endif
+
+  call ale#linter#Reset()
+
+
+Given javascript(A file with warnings/errors):
+  var x = 3 + 12345678
+  var x = 5*2 + parseInt("10");
+  // comment
+
+Execute(Floating preview is used with ALEDetail when g:ale_floating_preview set):
+  let g:ale_floating_preview = 1
+
+  call cursor(1, 10)
+
+  ALEDetail
+
+  let expected = ["Every statement should end with a semicolon", "second line"]
+
+  AssertEqual 1, g:floating_preview_show_called
+  AssertEqual expected, g:floated_lines
+
+Execute(Floating preview is used with ALEDetail when g:ale_detail_to_floating_preview set):
+  let g:ale_detail_to_floating_preview = 1
+
+  call cursor(1, 10)
+
+  ALEDetail
+
+  let expected = ["Every statement should end with a semicolon", "second line"]
+
+  AssertEqual 1, g:floating_preview_show_called
+  AssertEqual expected, g:floated_lines
+
+Execute(Floating preview is not used with ALEDetail by default):
+  call cursor(1, 10)
+
+  ALEDetail
+
+  AssertEqual 0, g:floating_preview_show_called