summaryrefslogtreecommitdiff
path: root/test/completion
diff options
context:
space:
mode:
Diffstat (limited to 'test/completion')
-rw-r--r--test/completion/test_completion_prefixes.vader9
-rw-r--r--test/completion/test_lsp_completion_messages.vader7
-rw-r--r--test/completion/test_tsserver_completion_parsing.vader74
3 files changed, 90 insertions, 0 deletions
diff --git a/test/completion/test_completion_prefixes.vader b/test/completion/test_completion_prefixes.vader
index a88e978d..0b2cfeaf 100644
--- a/test/completion/test_completion_prefixes.vader
+++ b/test/completion/test_completion_prefixes.vader
@@ -2,6 +2,8 @@ Given typescript():
let abc = y.
let foo = ab
let foo = (ab)
+ let string1 = '
+ let string2 = "
Execute(Completion should be done after dots in TypeScript):
AssertEqual '.', ale#completion#GetPrefix(&filetype, 1, 13)
@@ -15,6 +17,13 @@ Execute(Completion should be done after words in parens in TypeScript):
Execute(Completion should not be done after parens in TypeScript):
AssertEqual '', ale#completion#GetPrefix(&filetype, 3, 15)
+Execute(Completion should be done after strings in TypeScript):
+ AssertEqual '''', ale#completion#GetPrefix(&filetype, 4, 16)
+ AssertEqual '"', ale#completion#GetPrefix(&filetype, 5, 16)
+
+Execute(Completion prefixes should work for other filetypes):
+ AssertEqual 'ab', ale#completion#GetPrefix('xxxyyyzzz', 3, 14)
+
Execute(Completion prefixes should work for other filetypes):
AssertEqual 'ab', ale#completion#GetPrefix('xxxyyyzzz', 3, 14)
diff --git a/test/completion/test_lsp_completion_messages.vader b/test/completion/test_lsp_completion_messages.vader
index af3aa8c0..734b330c 100644
--- a/test/completion/test_lsp_completion_messages.vader
+++ b/test/completion/test_lsp_completion_messages.vader
@@ -41,6 +41,7 @@ After:
unlet! b:ale_completion_parser
unlet! b:ale_complete_done_time
unlet! b:ale_linters
+ unlet! b:ale_tsserver_completion_names
call ale#test#RestoreDirectory()
call ale#linter#Reset()
@@ -112,6 +113,12 @@ Execute(The right message sent to the tsserver LSP when the first completion mes
\ ],
\})
+ " We should save the names we got in the buffer, as TSServer doesn't return
+ " details for every name.
+ AssertEqual
+ \ ['Foo', 'FooBar', 'frazzle'],
+ \ get(b:, 'ale_tsserver_completion_names', [])
+
" The entry details messages should have been sent.
AssertEqual
\ [[
diff --git a/test/completion/test_tsserver_completion_parsing.vader b/test/completion/test_tsserver_completion_parsing.vader
index b663ef40..c8e2c993 100644
--- a/test/completion/test_tsserver_completion_parsing.vader
+++ b/test/completion/test_tsserver_completion_parsing.vader
@@ -1,3 +1,6 @@
+After:
+ unlet! b:ale_tsserver_completion_names
+
Execute(TypeScript completions responses should be parsed correctly):
AssertEqual [],
\ ale#completion#ParseTSServerCompletions({
@@ -73,3 +76,74 @@ Execute(TypeScript completion details responses should be parsed correctly):
\ },
\ ],
\})
+
+Execute(Entries without details should be included in the responses):
+ let b:ale_tsserver_completion_names = ['xyz']
+
+ AssertEqual
+ \ [
+ \ {
+ \ 'word': 'abc',
+ \ 'menu': '(property) Foo.abc: number',
+ \ 'info': '',
+ \ 'kind': 'f',
+ \ 'icase': 1,
+ \ },
+ \ {
+ \ 'word': 'def',
+ \ 'menu': '(property) Foo.def: number',
+ \ 'info': 'foo bar baz',
+ \ 'kind': 'f',
+ \ 'icase': 1,
+ \ },
+ \ {
+ \ 'word': 'xyz',
+ \ 'menu': '',
+ \ 'info': '',
+ \ 'kind': 'v',
+ \ 'icase': 1,
+ \ },
+ \ ],
+ \ ale#completion#ParseTSServerCompletionEntryDetails({
+ \ 'body': [
+ \ {
+ \ 'name': 'abc',
+ \ 'kind': 'parameterName',
+ \ 'displayParts': [
+ \ {'text': '('},
+ \ {'text': 'property'},
+ \ {'text': ')'},
+ \ {'text': ' '},
+ \ {'text': 'Foo'},
+ \ {'text': '.'},
+ \ {'text': 'abc'},
+ \ {'text': ':'},
+ \ {'text': ' '},
+ \ {'text': 'number'},
+ \ ],
+ \ },
+ \ {
+ \ 'name': 'def',
+ \ 'kind': 'parameterName',
+ \ 'displayParts': [
+ \ {'text': '('},
+ \ {'text': 'property'},
+ \ {'text': ')'},
+ \ {'text': ' '},
+ \ {'text': 'Foo'},
+ \ {'text': '.'},
+ \ {'text': 'def'},
+ \ {'text': ':'},
+ \ {'text': ' '},
+ \ {'text': 'number'},
+ \ ],
+ \ 'documentation': [
+ \ {'text': 'foo'},
+ \ {'text': ' '},
+ \ {'text': 'bar'},
+ \ {'text': ' '},
+ \ {'text': 'baz'},
+ \ ],
+ \ },
+ \ ],
+ \})