summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/completion/test_lsp_completion_messages.vader2
-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
-rw-r--r--test/test_find_references.vader18
-rw-r--r--test/test_go_to_definition.vader20
-rw-r--r--test/test_hover.vader1
7 files changed, 56 insertions, 10 deletions
diff --git a/test/completion/test_lsp_completion_messages.vader b/test/completion/test_lsp_completion_messages.vader
index 35b167b6..c83ad8e1 100644
--- a/test/completion/test_lsp_completion_messages.vader
+++ b/test/completion/test_lsp_completion_messages.vader
@@ -23,10 +23,10 @@ Before:
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': 'python',
\}
call add(g:init_callback_list, {-> a:Callback(a:linter, l:details)})
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
diff --git a/test/test_find_references.vader b/test/test_find_references.vader
index 078333bb..eb06e3bc 100644
--- a/test/test_find_references.vader
+++ b/test/test_find_references.vader
@@ -13,7 +13,7 @@ Before:
let g:conn_id = v:null
let g:InitCallback = v:null
- runtime autoload/ale/linter.vim
+ runtime autoload/ale/lsp_linter.vim
runtime autoload/ale/lsp.vim
runtime autoload/ale/util.vim
runtime autoload/ale/preview.vim
@@ -21,14 +21,19 @@ Before:
function! ale#lsp_linter#StartLSP(buffer, linter, Callback) abort
let g:conn_id = ale#lsp#Register('executable', '/foo/bar', {})
call ale#lsp#MarkDocumentAsOpen(g:conn_id, a:buffer)
+
+ if a:linter.lsp is# 'tsserver'
+ call ale#lsp#MarkConnectionAsTsserver(g:conn_id)
+ endif
+
let l:details = {
+ \ 'command': 'foobar',
\ 'buffer': a:buffer,
\ 'connection_id': g:conn_id,
\ 'project_root': '/foo/bar',
- \ 'language_id': 'python',
\}
- let g:InitCallback = {-> a:Callback(a:linter, l:details)}
+ let g:InitCallback = {-> ale#lsp_linter#OnInit(a:linter, l:details, a:Callback)}
endfunction
function! ale#lsp#HasCapability(conn_id, capability) abort
@@ -167,6 +172,8 @@ Execute(The preview window should not be opened for empty tsserver responses):
AssertEqual ['echom ''No references found.'''], g:expr_list
Execute(tsserver reference requests should be sent):
+ call ale#linter#Reset()
+
runtime ale_linters/typescript/tsserver.vim
call setpos('.', [bufnr(''), 2, 5, 0])
@@ -183,7 +190,10 @@ Execute(tsserver reference requests should be sent):
\ 'function(''ale#references#HandleTSServerResponse'')',
\ string(g:Callback)
AssertEqual
- \ [[0, 'ts@references', {'file': expand('%:p'), 'line': 2, 'offset': 5}]],
+ \ [
+ \ ale#lsp#tsserver_message#Change(bufnr('')),
+ \ [0, 'ts@references', {'file': expand('%:p'), 'line': 2, 'offset': 5}]
+ \ ],
\ g:message_list
AssertEqual {'42': {'use_relative_paths': 0}}, ale#references#GetMap()
diff --git a/test/test_go_to_definition.vader b/test/test_go_to_definition.vader
index 880d7123..452b7692 100644
--- a/test/test_go_to_definition.vader
+++ b/test/test_go_to_definition.vader
@@ -11,20 +11,26 @@ Before:
let g:InitCallback = v:null
runtime autoload/ale/linter.vim
+ runtime autoload/ale/lsp_linter.vim
runtime autoload/ale/lsp.vim
runtime autoload/ale/util.vim
function! ale#lsp_linter#StartLSP(buffer, linter, Callback) abort
let g:conn_id = ale#lsp#Register('executable', '/foo/bar', {})
call ale#lsp#MarkDocumentAsOpen(g:conn_id, a:buffer)
+
+ if a:linter.lsp is# 'tsserver'
+ call ale#lsp#MarkConnectionAsTsserver(g:conn_id)
+ endif
+
let l:details = {
+ \ 'command': 'foobar',
\ 'buffer': a:buffer,
\ 'connection_id': g:conn_id,
\ 'project_root': '/foo/bar',
- \ 'language_id': 'python',
\}
- let g:InitCallback = {-> a:Callback(a:linter, l:details)}
+ let g:InitCallback = {-> ale#lsp_linter#OnInit(a:linter, l:details, a:Callback)}
endfunction
function! ale#lsp#HasCapability(conn_id, capability) abort
@@ -215,7 +221,10 @@ Execute(tsserver definition requests should be sent):
\ 'function(''ale#definition#HandleTSServerResponse'')',
\ string(g:Callback)
AssertEqual
- \ [[0, 'ts@definition', {'file': expand('%:p'), 'line': 2, 'offset': 5}]],
+ \ [
+ \ ale#lsp#tsserver_message#Change(bufnr('')),
+ \ [0, 'ts@definition', {'file': expand('%:p'), 'line': 2, 'offset': 5}]
+ \ ],
\ g:message_list
AssertEqual {'42': {'open_in': 'current-buffer'}}, ale#definition#GetMap()
@@ -236,7 +245,10 @@ Execute(tsserver tab definition requests should be sent):
\ 'function(''ale#definition#HandleTSServerResponse'')',
\ string(g:Callback)
AssertEqual
- \ [[0, 'ts@definition', {'file': expand('%:p'), 'line': 2, 'offset': 5}]],
+ \ [
+ \ ale#lsp#tsserver_message#Change(bufnr('')),
+ \ [0, 'ts@definition', {'file': expand('%:p'), 'line': 2, 'offset': 5}]
+ \ ],
\ g:message_list
AssertEqual {'42': {'open_in': 'tab'}}, ale#definition#GetMap()
diff --git a/test/test_hover.vader b/test/test_hover.vader
index 13cfdbab..917694a2 100644
--- a/test/test_hover.vader
+++ b/test/test_hover.vader
@@ -15,6 +15,7 @@ Before:
let g:Callback = a:callback
return {
+ \ 'command': 'foobar',
\ 'connection_id': 347,
\ 'project_root': '/foo/bar',
\}