summaryrefslogtreecommitdiff
path: root/test/lsp
diff options
context:
space:
mode:
authorw0rp <devw0rp@gmail.com>2017-07-26 10:37:37 +0100
committerw0rp <devw0rp@gmail.com>2017-07-26 10:37:37 +0100
commitcd860e3e8d2b8d35920f27279bbd1ec346ac4d62 (patch)
tree03c63eb3e37d2e2b5761f3bbe3af7b1b0e8e05df /test/lsp
parent86297a7c65eadc5dc7668e129c92316aa0a89898 (diff)
downloadale-cd860e3e8d2b8d35920f27279bbd1ec346ac4d62.zip
#517 Add more code LSP support which makes the tssserver linter behave more like the LSP linters
Diffstat (limited to 'test/lsp')
-rw-r--r--test/lsp/test_lsp_client_messages.vader79
-rw-r--r--test/lsp/test_read_lsp_diagnostics.vader40
2 files changed, 60 insertions, 59 deletions
diff --git a/test/lsp/test_lsp_client_messages.vader b/test/lsp/test_lsp_client_messages.vader
index abf733ca..057abad4 100644
--- a/test/lsp/test_lsp_client_messages.vader
+++ b/test/lsp/test_lsp_client_messages.vader
@@ -1,10 +1,13 @@
Before:
silent! cd /testplugin/test/lsp
- let b:dir = getcwd()
+ let g:dir = getcwd()
+ let g:ale_lsp_next_version_id = 1
+
+ call ale#test#SetFilename('foo/bar.ts')
After:
- silent execute 'cd ' . fnameescape(b:dir)
- unlet! b:dir
+ silent execute 'cd ' . fnameescape(g:dir)
+ unlet! g:dir
Execute(ale#lsp#message#Initialize() should return correct messages):
AssertEqual
@@ -13,7 +16,7 @@ Execute(ale#lsp#message#Initialize() should return correct messages):
\ 'initialize',
\ {
\ 'processId': getpid(),
- \ 'rootUri': '/foo/bar',
+ \ 'rootPath': '/foo/bar',
\ 'capabilities': {},
\ }
\ ],
@@ -28,36 +31,51 @@ Execute(ale#lsp#message#Shutdown() should return correct messages):
Execute(ale#lsp#message#Exit() should return correct messages):
AssertEqual [1, 'exit'], ale#lsp#message#Exit(),
+Given typescript(A TypeScript file with 3 lines):
+ foo()
+ bar()
+ baz()
+
Execute(ale#lsp#message#DidOpen() should return correct messages):
+ let g:ale_lsp_next_version_id = 12
AssertEqual
\ [
\ 1,
\ 'textDocument/didOpen',
\ {
\ 'textDocument': {
- \ 'uri': '/foo/bar',
+ \ 'uri': 'file://' . g:dir . '/foo/bar.ts',
\ 'languageId': 'typescript',
- \ 'version': 123,
- \ 'text': 'foobar',
+ \ 'version': 12,
+ \ 'text': "foo()\nbar()\nbaz()",
\ },
\ }
\ ],
- \ ale#lsp#message#DidOpen('/foo/bar', 'typescript', 123, 'foobar')
+ \ ale#lsp#message#DidOpen(bufnr(''), 'typescript')
Execute(ale#lsp#message#DidChange() should return correct messages):
+ let g:ale_lsp_next_version_id = 34
+
AssertEqual
\ [
\ 1,
\ 'textDocument/didChange',
\ {
\ 'textDocument': {
- \ 'uri': '/foo/bar',
- \ 'version': 123,
+ \ 'uri': 'file://' . g:dir . '/foo/bar.ts',
+ \ 'version': 34,
\ },
- \ 'contentChanges': [{'text': 'foobar'}],
+ \ 'contentChanges': [{'text': "foo()\nbar()\nbaz()"}],
\ }
\ ],
- \ ale#lsp#message#DidChange('/foo/bar', 123, 'foobar')
+ \ ale#lsp#message#DidChange(bufnr(''))
+ " The version numbers should increment.
+ AssertEqual
+ \ 35,
+ \ ale#lsp#message#DidChange(bufnr(''))[2].textDocument.version
+ AssertEqual
+ \ 36,
+ \ ale#lsp#message#DidChange(bufnr(''))[2].textDocument.version
Execute(ale#lsp#message#DidSave() should return correct messages):
AssertEqual
@@ -66,11 +84,11 @@ Execute(ale#lsp#message#DidSave() should return correct messages):
\ 'textDocument/didSave',
\ {
\ 'textDocument': {
- \ 'uri': '/foo/bar',
+ \ 'uri': 'file://' . g:dir . '/foo/bar.ts',
\ },
\ }
\ ],
- \ ale#lsp#message#DidSave('/foo/bar')
+ \ ale#lsp#message#DidSave(bufnr(''))
Execute(ale#lsp#message#DidClose() should return correct messages):
AssertEqual
@@ -79,52 +97,41 @@ Execute(ale#lsp#message#DidClose() should return correct messages):
\ 'textDocument/didClose',
\ {
\ 'textDocument': {
- \ 'uri': '/foo/bar',
+ \ 'uri': 'file://' . g:dir . '/foo/bar.ts',
\ },
\ }
\ ],
- \ ale#lsp#message#DidClose('/foo/bar')
+ \ ale#lsp#message#DidClose(bufnr(''))
Execute(ale#lsp#tsserver_message#Open() should return correct messages):
- silent! noautocmd file foo.ts
-
AssertEqual
\ [
\ 1,
\ 'ts@open',
\ {
- \ 'file': b:dir . '/foo.ts',
+ \ 'file': g:dir . '/foo/bar.ts',
\ }
\ ],
\ ale#lsp#tsserver_message#Open(bufnr(''))
Execute(ale#lsp#tsserver_message#Close() should return correct messages):
- silent! noautocmd file foo.ts
-
AssertEqual
\ [
\ 1,
\ 'ts@close',
\ {
- \ 'file': b:dir . '/foo.ts',
+ \ 'file': g:dir . '/foo/bar.ts',
\ }
\ ],
\ ale#lsp#tsserver_message#Close(bufnr(''))
-Given typescript(A TypeScript file with 3 lines):
- foo()
- bar()
- baz()
-
Execute(ale#lsp#tsserver_message#Change() should return correct messages):
- silent! noautocmd file foo.ts
-
AssertEqual
\ [
\ 1,
\ 'ts@change',
\ {
- \ 'file': b:dir . '/foo.ts',
+ \ 'file': g:dir . '/foo/bar.ts',
\ 'line': 1,
\ 'offset': 1,
\ 'endLine': 1073741824,
@@ -135,27 +142,23 @@ Execute(ale#lsp#tsserver_message#Change() should return correct messages):
\ ale#lsp#tsserver_message#Change(bufnr(''))
Execute(ale#lsp#tsserver_message#Geterr() should return correct messages):
- silent! noautocmd file foo.ts
-
AssertEqual
\ [
\ 1,
\ 'ts@geterr',
\ {
- \ 'files': [b:dir . '/foo.ts'],
+ \ 'files': [g:dir . '/foo/bar.ts'],
\ }
\ ],
\ ale#lsp#tsserver_message#Geterr(bufnr(''))
Execute(ale#lsp#tsserver_message#Completions() should return correct messages):
- silent! noautocmd file foo.ts
-
AssertEqual
\ [
\ 0,
\ 'ts@completions',
\ {
- \ 'file': b:dir . '/foo.ts',
+ \ 'file': g:dir . '/foo/bar.ts',
\ 'line': 347,
\ 'offset': 12,
\ 'prefix': 'abc',
@@ -164,14 +167,12 @@ Execute(ale#lsp#tsserver_message#Completions() should return correct messages):
\ ale#lsp#tsserver_message#Completions(bufnr(''), 347, 12, 'abc')
Execute(ale#lsp#tsserver_message#CompletionEntryDetails() should return correct messages):
- silent! noautocmd file foo.ts
-
AssertEqual
\ [
\ 0,
\ 'ts@completionEntryDetails',
\ {
- \ 'file': b:dir . '/foo.ts',
+ \ 'file': g:dir . '/foo/bar.ts',
\ 'line': 347,
\ 'offset': 12,
\ 'entryNames': ['foo', 'bar'],
diff --git a/test/lsp/test_read_lsp_diagnostics.vader b/test/lsp/test_read_lsp_diagnostics.vader
index 63086a7f..3e637418 100644
--- a/test/lsp/test_read_lsp_diagnostics.vader
+++ b/test/lsp/test_read_lsp_diagnostics.vader
@@ -10,7 +10,7 @@ After:
delfunction Range
Execute(ale#lsp#response#ReadDiagnostics() should handle errors):
- AssertEqual ['filename.ts', [
+ AssertEqual [
\ {
\ 'type': 'E',
\ 'text': 'Something went wrong!',
@@ -20,18 +20,18 @@ Execute(ale#lsp#response#ReadDiagnostics() should handle errors):
\ 'end_col': 16,
\ 'nr': 'some-error',
\ }
- \ ]],
- \ ale#lsp#response#ReadDiagnostics({'uri': 'filename.ts', 'diagnostics': [
+ \ ],
+ \ ale#lsp#response#ReadDiagnostics({'params': {'uri': 'filename.ts', 'diagnostics': [
\ {
\ 'severity': 1,
\ 'range': Range(2, 10, 4, 15),
\ 'code': 'some-error',
\ 'message': 'Something went wrong!',
\ },
- \ ]})
+ \ ]}})
Execute(ale#lsp#response#ReadDiagnostics() should handle warnings):
- AssertEqual ['filename.ts', [
+ AssertEqual [
\ {
\ 'type': 'W',
\ 'text': 'Something went wrong!',
@@ -41,18 +41,18 @@ Execute(ale#lsp#response#ReadDiagnostics() should handle warnings):
\ 'end_col': 4,
\ 'nr': 'some-warning',
\ }
- \ ]],
- \ ale#lsp#response#ReadDiagnostics({'uri': 'filename.ts', 'diagnostics': [
+ \ ],
+ \ ale#lsp#response#ReadDiagnostics({'params': {'uri': 'filename.ts', 'diagnostics': [
\ {
\ 'severity': 2,
\ 'range': Range(1, 3, 1, 3),
\ 'code': 'some-warning',
\ 'message': 'Something went wrong!',
\ },
- \ ]})
+ \ ]}})
Execute(ale#lsp#response#ReadDiagnostics() should treat messages with missing severity as errors):
- AssertEqual ['filename.ts', [
+ AssertEqual [
\ {
\ 'type': 'E',
\ 'text': 'Something went wrong!',
@@ -62,17 +62,17 @@ Execute(ale#lsp#response#ReadDiagnostics() should treat messages with missing se
\ 'end_col': 16,
\ 'nr': 'some-error',
\ }
- \ ]],
- \ ale#lsp#response#ReadDiagnostics({'uri': 'filename.ts', 'diagnostics': [
+ \ ],
+ \ ale#lsp#response#ReadDiagnostics({'params': {'uri': 'filename.ts', 'diagnostics': [
\ {
\ 'range': Range(2, 10, 4, 15),
\ 'code': 'some-error',
\ 'message': 'Something went wrong!',
\ },
- \ ]})
+ \ ]}})
Execute(ale#lsp#response#ReadDiagnostics() should handle messages without codes):
- AssertEqual ['filename.ts', [
+ AssertEqual [
\ {
\ 'type': 'E',
\ 'text': 'Something went wrong!',
@@ -81,16 +81,16 @@ Execute(ale#lsp#response#ReadDiagnostics() should handle messages without codes)
\ 'end_lnum': 5,
\ 'end_col': 16,
\ }
- \ ]],
- \ ale#lsp#response#ReadDiagnostics({'uri': 'filename.ts', 'diagnostics': [
+ \ ],
+ \ ale#lsp#response#ReadDiagnostics({'params': {'uri': 'filename.ts', 'diagnostics': [
\ {
\ 'range': Range(2, 10, 4, 15),
\ 'message': 'Something went wrong!',
\ },
- \ ]})
+ \ ]}})
Execute(ale#lsp#response#ReadDiagnostics() should handle multiple messages):
- AssertEqual ['filename.ts', [
+ AssertEqual [
\ {
\ 'type': 'E',
\ 'text': 'Something went wrong!',
@@ -107,8 +107,8 @@ Execute(ale#lsp#response#ReadDiagnostics() should handle multiple messages):
\ 'end_lnum': 2,
\ 'end_col': 5,
\ },
- \ ]],
- \ ale#lsp#response#ReadDiagnostics({'uri': 'filename.ts', 'diagnostics': [
+ \ ],
+ \ ale#lsp#response#ReadDiagnostics({'params': {'uri': 'filename.ts', 'diagnostics': [
\ {
\ 'range': Range(0, 2, 0, 2),
\ 'message': 'Something went wrong!',
@@ -118,7 +118,7 @@ Execute(ale#lsp#response#ReadDiagnostics() should handle multiple messages):
\ 'range': Range(1, 4, 1, 4),
\ 'message': 'A warning',
\ },
- \ ]})
+ \ ]}})
Execute(ale#lsp#response#ReadTSServerDiagnostics() should handle tsserver responses):
AssertEqual [