summaryrefslogtreecommitdiff
path: root/test/completion
diff options
context:
space:
mode:
authorw0rp <devw0rp@gmail.com>2020-08-09 02:28:47 +0100
committerw0rp <devw0rp@gmail.com>2020-08-09 02:32:47 +0100
commit6d502233d849600ecb2a08227299ffea2b2ea0c7 (patch)
tree88748791203d0a8beefd2110b59819be762da9c8 /test/completion
parent8bfb5c64073cf12018e5b7e115867b2ef4dfa7e0 (diff)
downloadale-6d502233d849600ecb2a08227299ffea2b2ea0c7.zip
Close #3267 - Add a general autoimport setting
Diffstat (limited to 'test/completion')
-rw-r--r--test/completion/test_lsp_completion_messages.vader2
-rw-r--r--test/completion/test_lsp_completion_parsing.vader51
-rw-r--r--test/completion/test_tsserver_completion_parsing.vader10
3 files changed, 56 insertions, 7 deletions
diff --git a/test/completion/test_lsp_completion_messages.vader b/test/completion/test_lsp_completion_messages.vader
index 4b7392f5..ee810113 100644
--- a/test/completion/test_lsp_completion_messages.vader
+++ b/test/completion/test_lsp_completion_messages.vader
@@ -121,7 +121,7 @@ Execute(The right message should be sent for the initial tsserver request):
\ 'line': 1,
\ 'offset': 3,
\ 'prefix': 'fo',
- \ 'includeExternalModuleExports': g:ale_completion_tsserver_autoimport,
+ \ 'includeExternalModuleExports': g:ale_completion_autoimport,
\ }]],
\ g:message_list
" We should set up the completion info correctly.
diff --git a/test/completion/test_lsp_completion_parsing.vader b/test/completion/test_lsp_completion_parsing.vader
index e233c955..8b8b41c7 100644
--- a/test/completion/test_lsp_completion_parsing.vader
+++ b/test/completion/test_lsp_completion_parsing.vader
@@ -1,4 +1,12 @@
+Before:
+ Save g:ale_completion_autoimport
+ Save g:ale_completion_max_suggestions
+
+ let g:ale_completion_max_suggestions = 50
+
After:
+ Restore
+
unlet! b:ale_completion_info
Execute(Should handle Rust completion results correctly):
@@ -527,7 +535,9 @@ Execute(Should handle completion messages with the deprecated insertText attribu
\ },
\ })
-Execute(Should handle completion messages with additionalTextEdits):
+Execute(Should handle completion messages with additionalTextEdits when ale_completion_autoimport is turned on):
+ let g:ale_completion_autoimport = 1
+
AssertEqual
\ [
\ {
@@ -596,3 +606,42 @@ Execute(Should handle completion messages with additionalTextEdits):
\ ],
\ },
\ })
+
+Execute(Should not handle completion messages with additionalTextEdits when ale_completion_autoimport is turned off):
+ let g:ale_completion_autoimport = 0
+
+ AssertEqual
+ \ [],
+ \ ale#completion#ParseLSPCompletions({
+ \ 'id': 226,
+ \ 'jsonrpc': '2.0',
+ \ 'result': {
+ \ 'isIncomplete': v:false,
+ \ 'items': [
+ \ {
+ \ 'detail': 'PlayTimeCallback',
+ \ 'filterText': 'next_callback',
+ \ 'insertText': 'next_callback',
+ \ 'insertTextFormat': 1,
+ \ 'kind': 6,
+ \ 'label': ' next_callback',
+ \ 'sortText': '3ee19999next_callback',
+ \ 'additionalTextEdits': [
+ \ {
+ \ 'range': {
+ \ 'start': {
+ \ 'line': 10,
+ \ 'character': 1,
+ \ },
+ \ 'end': {
+ \ 'line': 12,
+ \ 'character': 3,
+ \ },
+ \ },
+ \ 'newText': 'from "module" import next_callback',
+ \ },
+ \ ],
+ \ },
+ \ ],
+ \ },
+ \ })
diff --git a/test/completion/test_tsserver_completion_parsing.vader b/test/completion/test_tsserver_completion_parsing.vader
index 58b56ce6..4515afd1 100644
--- a/test/completion/test_tsserver_completion_parsing.vader
+++ b/test/completion/test_tsserver_completion_parsing.vader
@@ -83,7 +83,7 @@ Execute(TypeScript completion details responses should be parsed correctly):
\ 'info': '',
\ 'kind': 'v',
\ 'icase': 1,
- \ 'dup': g:ale_completion_tsserver_autoimport,
+ \ 'dup': g:ale_completion_autoimport,
\ },
\ {
\ 'word': 'def',
@@ -91,7 +91,7 @@ Execute(TypeScript completion details responses should be parsed correctly):
\ 'info': 'foo bar baz',
\ 'kind': 'v',
\ 'icase': 1,
- \ 'dup': g:ale_completion_tsserver_autoimport,
+ \ 'dup': g:ale_completion_autoimport,
\ },
\ {
\ 'word': 'ghi',
@@ -99,7 +99,7 @@ Execute(TypeScript completion details responses should be parsed correctly):
\ 'info': '',
\ 'kind': 'v',
\ 'icase': 1,
- \ 'dup': g:ale_completion_tsserver_autoimport,
+ \ 'dup': g:ale_completion_autoimport,
\ },
\ ],
\ ale#completion#ParseTSServerCompletionEntryDetails({
@@ -177,7 +177,7 @@ Execute(Entries without details should be included in the responses):
\ 'changes': [],
\ }],
\ }),
- \ 'dup': g:ale_completion_tsserver_autoimport,
+ \ 'dup': g:ale_completion_autoimport,
\ },
\ {
\ 'word': 'def',
@@ -185,7 +185,7 @@ Execute(Entries without details should be included in the responses):
\ 'info': 'foo bar baz',
\ 'kind': 'v',
\ 'icase': 1,
- \ 'dup': g:ale_completion_tsserver_autoimport,
+ \ 'dup': g:ale_completion_autoimport,
\ },
\ {
\ 'word': 'xyz',