diff options
Diffstat (limited to 'test/functional')
-rw-r--r-- | test/functional/lua/ui_spec.lua | 25 | ||||
-rw-r--r-- | test/functional/plugin/lsp_spec.lua | 6 |
2 files changed, 28 insertions, 3 deletions
diff --git a/test/functional/lua/ui_spec.lua b/test/functional/lua/ui_spec.lua index 94f1b5840b..2371939204 100644 --- a/test/functional/lua/ui_spec.lua +++ b/test/functional/lua/ui_spec.lua @@ -43,4 +43,29 @@ describe('vim.ui', function() }, result[2]) end) end) + + describe('input', function() + it('can input text', function() + local result = exec_lua[[ + local opts = { + prompt = 'Input: ', + } + local input + local cb = function(item) + input = item + end + -- input would require input and block the test; + local prompt + vim.fn.input = function(opts) + prompt = opts.prompt + return "Inputted text" + end + vim.ui.input(opts, cb) + vim.wait(100, function() return input ~= nil end) + return {input, prompt} + ]] + eq('Inputted text', result[1]) + eq('Input: ', result[2]) + end) + end) end) diff --git a/test/functional/plugin/lsp_spec.lua b/test/functional/plugin/lsp_spec.lua index c025e9f4ab..ae7612ab08 100644 --- a/test/functional/plugin/lsp_spec.lua +++ b/test/functional/plugin/lsp_spec.lua @@ -2435,9 +2435,9 @@ describe('LSP', function() local bufnr = vim.api.nvim_get_current_buf() lsp.buf_attach_client(bufnr, TEST_RPC_CLIENT_ID) vim.lsp._stubs = {} - vim.fn.input = function(prompt, text) - vim.lsp._stubs.input_prompt = prompt - vim.lsp._stubs.input_text = text + vim.fn.input = function(opts, on_confirm) + vim.lsp._stubs.input_prompt = opts.prompt + vim.lsp._stubs.input_text = opts.default return 'renameto' -- expect this value in fake lsp end vim.api.nvim_buf_set_lines(bufnr, 0, -1, false, {'', 'this is line two'}) |