diff options
Diffstat (limited to 'test/functional/lua/snippet_spec.lua')
-rw-r--r-- | test/functional/lua/snippet_spec.lua | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/test/functional/lua/snippet_spec.lua b/test/functional/lua/snippet_spec.lua index 70337d1572..bf43d5114f 100644 --- a/test/functional/lua/snippet_spec.lua +++ b/test/functional/lua/snippet_spec.lua @@ -6,6 +6,7 @@ local exec_lua = helpers.exec_lua local feed = helpers.feed local matches = helpers.matches local pcall_err = helpers.pcall_err +local sleep = helpers.sleep describe('vim.snippet', function() before_each(function() @@ -171,4 +172,30 @@ describe('vim.snippet', function() feed('<esc>O-- A comment') eq(false, exec_lua('return vim.snippet.active()')) end) + + it('inserts choice', function () + test_success({ 'console.${1|assert,log,error|}()' }, { 'console.()' }) + sleep(100) + feed('<Down><C-y>') + eq({ 'console.log()' }, helpers.buf_lines(0)) + end) + + it('closes the choice completion menu when jumping', function () + test_success({ 'console.${1|assert,log,error|}($2)' }, { 'console.()' }) + sleep(100) + exec_lua('vim.snippet.jump(1)') + eq(0, exec_lua('return vim.fn.pumvisible()')) + end) + + it('jumps to next tabstop after inserting choice', function() + test_success( + { '${1|public,protected,private|} function ${2:name}() {', '\t$0', '}' }, + { ' function name() {', '\t', '}' } + ) + sleep(100) + feed('<C-y><Tab>') + sleep(10) + feed('foo') + eq({ 'public function foo() {', '\t', '}' }, helpers.buf_lines(0)) + end) end) |