diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2022-04-17 19:07:52 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2022-04-17 19:07:52 +0800 |
commit | 096ff4ef464af5eda4a45ad4daec813fd362e532 (patch) | |
tree | 783f357cc929af4f270d5edb7914f75242bb70c3 /test/tclient/tests | |
parent | a3799601ff7eff899667674c56c635c6a4c71ebc (diff) | |
download | lua-language-server-096ff4ef464af5eda4a45ad4daec813fd362e532.zip |
create test
Diffstat (limited to 'test/tclient/tests')
-rw-r--r-- | test/tclient/tests/resolve-completion.lua | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/test/tclient/tests/resolve-completion.lua b/test/tclient/tests/resolve-completion.lua new file mode 100644 index 00000000..a7cf2c2f --- /dev/null +++ b/test/tclient/tests/resolve-completion.lua @@ -0,0 +1,58 @@ +local lclient = require 'lclient' +local ws = require 'workspace' +local util = require 'utility' + +---@async +lclient():start(function (client) + client:registerFakers() + client:initialize() + + client:notify('textDocument/didOpen', { + textDocument = { + uri = 'file://test.lua', + languageId = 'lua', + version = 0, + text = [[ +---@type integer +local xxxx + +x +]] + } + }) + + ws.awaitReady() + + local completions = client:awaitRequest('textDocument/completion', { + textDocument = { uri = 'file://test.lua' }, + position = { line = 3, character = 1 }, + }) + + client:awaitRequest('textDocument/didChange', + { + textDocument = { uri = 'file://test.lua' }, + contentChanges = { + { + range = { + start = { line = 3, character = 1 }, + ['end'] = { line = 3, character = 1 }, + }, + text = 'x' + } + } + }) + + local targetItem + for _, item in ipairs(completions.items) do + if item.label == 'xxxx' then + targetItem = item + break + end + end + + assert(targetItem ~= nil) + + local newItem = client:awaitRequest('completionItem/resolve', targetItem) + + assert(newItem.detail == 'integer') +end) |