From 096ff4ef464af5eda4a45ad4daec813fd362e532 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Sun, 17 Apr 2022 19:07:52 +0800 Subject: create test --- test/tclient/tests/resolve-completion.lua | 58 +++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 test/tclient/tests/resolve-completion.lua (limited to 'test/tclient/tests/resolve-completion.lua') 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) -- cgit v1.2.3