From 33b4a905079c0d8ecafc265c0a31b3141b034b87 Mon Sep 17 00:00:00 2001 From: Horacio Sanson Date: Thu, 23 May 2019 10:19:50 +0900 Subject: [PATCH] Add tests for LSP responses --- test/test_engine_lsp_response_handling.vader | 87 ++++++++++++++++++++ 1 file changed, 87 insertions(+) diff --git a/test/test_engine_lsp_response_handling.vader b/test/test_engine_lsp_response_handling.vader index aeb13a86..34b0de3b 100644 --- a/test/test_engine_lsp_response_handling.vader +++ b/test/test_engine_lsp_response_handling.vader @@ -244,6 +244,93 @@ Execute(tsserver errors should mark tsserver no longer active): AssertEqual [], g:ale_buffer_info[bufnr('')].active_linter_list +Execute(LSP diagnostics responses should be handled correctly): + let b:ale_linters = ['eclipselsp'] + runtime ale_linters/java/eclipselsp.vim + call ale#test#SetFilename('filename.java') + call ale#engine#InitBufferInfo(bufnr('')) + call ale#lsp_linter#SetLSPLinterMap({'1': 'eclipselsp'}) + + call ale#lsp_linter#HandleLSPResponse(1, { + \ 'jsonrpc':'2.0', + \ 'method':'textDocument/publishDiagnostics', + \ 'params': { + \ 'uri':'file://' . g:dir . '/filename.java', + \ 'diagnostics': [ + \ { + \ 'range': { + \ 'start': { + \ 'line': 0, + \ 'character':0 + \ }, + \ 'end': { + \ 'line': 0, + \ 'character':0 + \ } + \ }, + \ 'severity': 2, + \ 'code': "", + \ 'source': 'Java', + \ 'message': 'Missing JRE 1-8' + \ } + \ ] + \ } + \}) + + AssertEqual + \ [ + \ { + \ 'lnum': 1, + \ 'bufnr': 3, + \ 'col': 1, + \ 'pattern': '', + \ 'valid': 1, + \ 'vcol': 0, + \ 'nr': -1, + \ 'type': 'W', + \ 'text': 'Missing JRE 1-8' + \ } + \ ], + \ ale#test#GetLoclistWithoutModule() + +Execute(LSP diagnostics responses on project root should not populate loclist): + let b:ale_linters = ['eclipselsp'] + runtime ale_linters/java/eclipselsp.vim + call ale#test#SetFilename('filename.java') + call ale#engine#InitBufferInfo(bufnr('')) + call ale#lsp_linter#SetLSPLinterMap({'1': 'eclipselsp'}) + + call ale#lsp_linter#HandleLSPResponse(1, { + \ 'jsonrpc':'2.0', + \ 'method':'textDocument/publishDiagnostics', + \ 'params': { + \ 'uri':'file://' . g:dir, + \ 'diagnostics': [ + \ { + \ 'range': { + \ 'start': { + \ 'line': 0, + \ 'character':0 + \ }, + \ 'end': { + \ 'line': 0, + \ 'character':0 + \ } + \ }, + \ 'severity': 2, + \ 'code': "", + \ 'source': 'Java', + \ 'message': 'Missing JRE 1-8' + \ } + \ ] + \ } + \}) + + AssertEqual + \ [ + \ ], + \ ale#test#GetLoclistWithoutModule() + Execute(LSP errors should mark linters no longer active): let b:ale_linters = ['pyls'] runtime ale_linters/python/pyls.vim