completedone_spec.lua 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. local t = require('test.testutil')
  2. local n = require('test.functional.testnvim')()
  3. local clear = n.clear
  4. local command = n.command
  5. local call = n.call
  6. local feed = n.feed
  7. local eval = n.eval
  8. local eq = t.eq
  9. describe('CompleteDone', function()
  10. before_each(clear)
  11. describe('sets v:event.reason', function()
  12. before_each(function()
  13. clear()
  14. command('autocmd CompleteDone * let g:donereason = v:event.reason')
  15. feed('i')
  16. call('complete', call('col', '.'), { 'foo', 'bar' })
  17. end)
  18. it('accept', function()
  19. feed('<C-y>')
  20. eq('accept', eval('g:donereason'))
  21. end)
  22. describe('cancel', function()
  23. it('on <C-e>', function()
  24. feed('<C-e>')
  25. eq('cancel', eval('g:donereason'))
  26. end)
  27. it('on non-keyword character', function()
  28. feed('<Esc>')
  29. eq('cancel', eval('g:donereason'))
  30. end)
  31. it('when overridden by another complete()', function()
  32. call('complete', call('col', '.'), { 'bar', 'baz' })
  33. eq('cancel', eval('g:donereason'))
  34. end)
  35. end)
  36. end)
  37. end)