diff options
Diffstat (limited to 'test/completion/test_tsserver_completion_parsing.vader')
-rw-r--r-- | test/completion/test_tsserver_completion_parsing.vader | 113 |
1 files changed, 108 insertions, 5 deletions
diff --git a/test/completion/test_tsserver_completion_parsing.vader b/test/completion/test_tsserver_completion_parsing.vader index 6beb7b0a..aaaaae95 100644 --- a/test/completion/test_tsserver_completion_parsing.vader +++ b/test/completion/test_tsserver_completion_parsing.vader @@ -1,4 +1,11 @@ +Before: + Save g:ale_completion_tsserver_remove_warnings + + let g:ale_completion_tsserver_remove_warnings = 0 + After: + Restore + unlet! b:ale_tsserver_completion_names Execute(TypeScript completions responses should be parsed correctly): @@ -29,6 +36,51 @@ Execute(TypeScript completions responses should be parsed correctly): \ ], \}) +Execute(TypeScript completions responses should include warnings): + AssertEqual + \ [ + \ { + \ 'word': 'foo', + \ 'source': '/path/to/foo.ts', + \ }, + \ { + \ 'word': 'bar', + \ 'source': '', + \ }, + \ { + \ 'word': 'baz', + \ 'source': '', + \ } + \ ], + \ ale#completion#ParseTSServerCompletions({ + \ 'body': [ + \ {'name': 'foo', 'source': '/path/to/foo.ts'}, + \ {'name': 'bar', 'kind': 'warning'}, + \ {'name': 'baz'}, + \ ], + \}) + +Execute(TypeScript completions responses should not include warnings if excluded): + let g:ale_completion_tsserver_remove_warnings = 1 + AssertEqual + \ [ + \ { + \ 'word': 'foo', + \ 'source': '/path/to/foo.ts', + \ }, + \ { + \ 'word': 'baz', + \ 'source': '', + \ } + \ ], + \ ale#completion#ParseTSServerCompletions({ + \ 'body': [ + \ {'name': 'foo', 'source': '/path/to/foo.ts'}, + \ {'name': 'bar', 'kind': 'warning'}, + \ {'name': 'baz'}, + \ ], + \}) + Execute(TypeScript completion details responses should be parsed correctly): AssertEqual \ [ @@ -38,7 +90,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', @@ -46,7 +98,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', @@ -54,7 +106,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({ @@ -132,7 +184,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', @@ -140,7 +192,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', @@ -197,3 +249,54 @@ Execute(Entries without details should be included in the responses): \ }, \ ], \}) + +Execute(Default imports should be handled correctly): + AssertEqual + \ [ + \ { + \ 'word': 'abcd', + \ 'menu': 'Import default ''abcd'' from module "./foo" (alias) const abcd: 3', + \ 'info': '', + \ 'kind': 't', + \ 'icase': 1, + \ 'user_data': json_encode({ + \ 'codeActions': [{ + \ 'description': 'Import default ''abcd'' from module "./foo"', + \ 'changes': [], + \ }], + \ }), + \ 'dup': g:ale_completion_autoimport, + \ }, + \ ], + \ ale#completion#ParseTSServerCompletionEntryDetails({ + \ 'body': [ + \ { + \ 'name': 'default', + \ 'kind': 'alias', + \ 'displayParts': [ + \ {'kind': 'punctuation', 'text': '('}, + \ {'kind': 'text', 'text': 'alias'}, + \ {'kind': 'punctuation', 'text': ')'}, + \ {'kind': 'space', 'text': ' '}, + \ {'kind': 'keyword', 'text': 'const'}, + \ {'kind': 'space', 'text': ' '}, + \ {'kind': 'localName', 'text': 'abcd'}, + \ {'kind': 'punctuation', 'text': ':'}, + \ {'kind': 'space', 'text': ' '}, + \ {'kind': 'stringLiteral', 'text': '3'}, + \ {'kind': 'lineBreak', 'text': '^@'}, + \ {'kind': 'keyword', 'text': 'export'}, + \ {'kind': 'space', 'text': ' '}, + \ {'kind': 'keyword', 'text': 'default'}, + \ {'kind': 'space', 'text': ' '}, + \ {'kind': 'aliasName', 'text': 'abcd'} + \ ], + \ 'codeActions': [ + \ { + \ 'description': 'Import default ''abcd'' from module "./foo"', + \ 'changes': [], + \ }, + \ ], + \ }, + \ ], + \ }) |