diff options
author | w0rp <devw0rp@gmail.com> | 2017-06-07 17:05:28 +0100 |
---|---|---|
committer | w0rp <devw0rp@gmail.com> | 2017-06-07 17:05:34 +0100 |
commit | f61c6d4c0ed9827aa0b798dc39233817b0813380 (patch) | |
tree | 69b47447b6eaaaf412169182434cc3694a51d5ce /test/lsp | |
parent | 71257979aa0916a66e8359505c4424888d80fd80 (diff) | |
download | ale-f61c6d4c0ed9827aa0b798dc39233817b0813380.zip |
Add support for generating essential tsserver messages
Diffstat (limited to 'test/lsp')
-rw-r--r-- | test/lsp/test_lsp_client_messages.vader | 70 | ||||
-rw-r--r-- | test/lsp/test_lsp_connections.vader | 58 |
2 files changed, 128 insertions, 0 deletions
diff --git a/test/lsp/test_lsp_client_messages.vader b/test/lsp/test_lsp_client_messages.vader index de18a4b8..a967e4ec 100644 --- a/test/lsp/test_lsp_client_messages.vader +++ b/test/lsp/test_lsp_client_messages.vader @@ -1,3 +1,11 @@ +Before: + silent! cd /testplugin/test/lsp + let b:dir = getcwd() + +After: + silent execute 'cd ' . fnameescape(b:dir) + unlet! b:dir + Execute(ale#lsp#message#Initialize() should return correct messages): AssertEqual \ [ @@ -76,3 +84,65 @@ Execute(ale#lsp#message#DidClose() should return correct messages): \ } \ ], \ ale#lsp#message#DidClose('/foo/bar') + +Execute(ale#lsp#tsserver_message#Open() should return correct messages): + silent! noautocmd file foo.ts + + AssertEqual + \ [ + \ 1, + \ 'ts@open', + \ { + \ 'file': b:dir . '/foo.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', + \ } + \ ], + \ 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', + \ 'line': 1, + \ 'offset': 1, + \ 'endLine': 3, + \ 'endOffset': 5, + \ 'insertString': "foo()\nbar()\nbaz()", + \ } + \ ], + \ 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'], + \ } + \ ], + \ ale#lsp#tsserver_message#Geterr(bufnr('')) diff --git a/test/lsp/test_lsp_connections.vader b/test/lsp/test_lsp_connections.vader index d5ed7702..82e3fc64 100644 --- a/test/lsp/test_lsp_connections.vader +++ b/test/lsp/test_lsp_connections.vader @@ -105,6 +105,64 @@ Execute(ale#lsp#CreateMessageData() should create notifications): \ ale#lsp#CreateMessageData([1, 'someNotification', {'foo': 'bar'}]) endif +Execute(ale#lsp#CreateMessageData() should create tsserver notification messages): + if has('nvim') + AssertEqual + \ [ + \ 0, + \ '{"seq": null, "type": "request", "command": "someNotification"}', + \ ], + \ ale#lsp#CreateMessageData([1, 'ts@someNotification']) + AssertEqual + \ [ + \ 0, + \ '{"seq": null, "arguments": {"foo": "bar"}, "type": "request", "command": "someNotification"}', + \ ], + \ ale#lsp#CreateMessageData([1, 'ts@someNotification', {'foo': 'bar'}]) + else + AssertEqual + \ [ + \ 0, + \ '{"seq":null,"type":"request","command":"someNotification"}', + \ ], + \ ale#lsp#CreateMessageData([1, 'ts@someNotification']) + AssertEqual + \ [ + \ 0, + \ '{"seq":null,"arguments":{"foo":"bar"},"type":"request","command":"someNotification"}', + \ ], + \ ale#lsp#CreateMessageData([1, 'ts@someNotification', {'foo': 'bar'}]) + endif + +Execute(ale#lsp#CreateMessageData() should create tsserver messages excepting responses): + if has('nvim') + AssertEqual + \ [ + \ 1, + \ '{"seq": 1, "type": "request", "command": "someMessage"}', + \ ], + \ ale#lsp#CreateMessageData([0, 'ts@someMessage']) + AssertEqual + \ [ + \ 2, + \ '{"seq": 2, "arguments": {"foo": "bar"}, "type": "request", "command": "someMessage"}', + \ ], + \ ale#lsp#CreateMessageData([0, 'ts@someMessage', {'foo': 'bar'}]) + else + AssertEqual + \ [ + \ 1, + \ '{"seq":1,"type":"request","command":"someMessage"}', + \ ], + \ ale#lsp#CreateMessageData([0, 'ts@someMessage']) + AssertEqual + \ [ + \ 2, + \ '{"seq":2,"arguments":{"foo":"bar"},"type":"request","command":"someMessage"}', + \ ], + \ ale#lsp#CreateMessageData([0, 'ts@someMessage', {'foo': 'bar'}]) + endif + Execute(ale#lsp#ReadMessageData() should read single whole messages): AssertEqual \ ['', [{'id': 2, 'jsonrpc': '2.0', 'result': {'foo': 'barÜ'}}]], |