summaryrefslogtreecommitdiff
path: root/test/lsp
diff options
context:
space:
mode:
authorw0rp <devw0rp@gmail.com>2019-02-15 08:54:53 +0000
committerw0rp <devw0rp@gmail.com>2019-02-15 08:54:53 +0000
commit0d10653a7c780ac98fd2b980679676f5e8f231e7 (patch)
treed8c0ad7b340dd281c725ed3a34e81f398ceec33a /test/lsp
parent89039187da89467d059cc13135e1b6cd867a68e9 (diff)
downloadale-0d10653a7c780ac98fd2b980679676f5e8f231e7.zip
Fix #2295 - Respond to initialize with an initialized message
Diffstat (limited to 'test/lsp')
-rw-r--r--test/lsp/test_did_save_event.vader2
-rw-r--r--test/lsp/test_other_initialize_message_handling.vader19
-rw-r--r--test/lsp/test_update_config.vader4
3 files changed, 24 insertions, 1 deletions
diff --git a/test/lsp/test_did_save_event.vader b/test/lsp/test_did_save_event.vader
index 1d6065ec..423138af 100644
--- a/test/lsp/test_did_save_event.vader
+++ b/test/lsp/test_did_save_event.vader
@@ -38,10 +38,10 @@ Before:
let g:conn_id = ale#lsp#Register('executable', '/foo/bar', {})
call ale#lsp#MarkDocumentAsOpen(g:conn_id, a:buffer)
let l:details = {
+ \ 'command': 'foobar',
\ 'buffer': a:buffer,
\ 'connection_id': g:conn_id,
\ 'project_root': '/foo/bar',
- \ 'language_id': 'foobar',
\}
call a:Callback(a:linter, l:details)
diff --git a/test/lsp/test_other_initialize_message_handling.vader b/test/lsp/test_other_initialize_message_handling.vader
index 8ae63e91..4150b9d7 100644
--- a/test/lsp/test_other_initialize_message_handling.vader
+++ b/test/lsp/test_other_initialize_message_handling.vader
@@ -1,5 +1,9 @@
Before:
+ runtime autoload/ale/lsp.vim
+
+ let g:message_list = []
let b:conn = {
+ \ 'id': 1,
\ 'is_tsserver': 0,
\ 'data': '',
\ 'root': '/foo/bar',
@@ -21,8 +25,17 @@ Before:
\ },
\}
+ function! ale#lsp#Send(conn_id, message) abort
+ call add(g:message_list, a:message)
+
+ return 42
+ endfunction
+
After:
unlet! b:conn
+ unlet! g:message_list
+
+ runtime autoload/ale/lsp.vim
Execute(Messages with no method and capabilities should initialize projects):
call ale#lsp#HandleInitResponse(b:conn, {
@@ -30,15 +43,18 @@ Execute(Messages with no method and capabilities should initialize projects):
\})
AssertEqual 1, b:conn.initialized
+ AssertEqual [[1, 'initialized']], g:message_list
Execute(Other messages should not initialize projects):
call ale#lsp#HandleInitResponse(b:conn, {'method': 'lolwat'})
AssertEqual 0, b:conn.initialized
+ AssertEqual [], g:message_list
call ale#lsp#HandleInitResponse(b:conn, {'result': {'x': {}}})
AssertEqual 0, b:conn.initialized
+ AssertEqual [], g:message_list
Execute(Capabilities should bet set up correctly):
call ale#lsp#HandleInitResponse(b:conn, {
@@ -86,6 +102,7 @@ Execute(Capabilities should bet set up correctly):
\ 'symbol_search': 1,
\ },
\ b:conn.capabilities
+ AssertEqual [[1, 'initialized']], g:message_list
Execute(Disabled capabilities should be recognised correctly):
call ale#lsp#HandleInitResponse(b:conn, {
@@ -128,6 +145,7 @@ Execute(Disabled capabilities should be recognised correctly):
\ 'symbol_search': 0,
\ },
\ b:conn.capabilities
+ AssertEqual [[1, 'initialized']], g:message_list
Execute(Results that are not dictionaries should be handled correctly):
call ale#lsp#HandleInitResponse(b:conn, {
@@ -135,3 +153,4 @@ Execute(Results that are not dictionaries should be handled correctly):
\ 'id': 1,
\ 'result': v:null,
\})
+ AssertEqual [], g:message_list
diff --git a/test/lsp/test_update_config.vader b/test/lsp/test_update_config.vader
index 07068bc8..698477ec 100644
--- a/test/lsp/test_update_config.vader
+++ b/test/lsp/test_update_config.vader
@@ -3,6 +3,10 @@ Before:
let g:conn_id = ale#lsp#Register('executable', '/foo/bar', {})
+ " Stub out this function, so we test updating configs.
+ function! ale#lsp#Send(conn_id, message) abort
+ endfunction
+
After:
Restore