recording_spec.lua 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. local t = require('test.testutil')
  2. local n = require('test.functional.testnvim')()
  3. local clear = n.clear
  4. local eq = t.eq
  5. local eval = n.eval
  6. local source_vim = n.source
  7. describe('RecordingEnter', function()
  8. before_each(clear)
  9. it('works', function()
  10. source_vim [[
  11. let g:recorded = 0
  12. autocmd RecordingEnter * let g:recorded += 1
  13. call feedkeys("qqyyq", 'xt')
  14. ]]
  15. eq(1, eval('g:recorded'))
  16. end)
  17. it('gives a correct reg_recording()', function()
  18. source_vim [[
  19. let g:recording = ''
  20. autocmd RecordingEnter * let g:recording = reg_recording()
  21. call feedkeys("qqyyq", 'xt')
  22. ]]
  23. eq('q', eval('g:recording'))
  24. end)
  25. end)
  26. describe('RecordingLeave', function()
  27. before_each(clear)
  28. it('works', function()
  29. source_vim [[
  30. let g:recorded = 0
  31. autocmd RecordingLeave * let g:recorded += 1
  32. call feedkeys("qqyyq", 'xt')
  33. ]]
  34. eq(1, eval('g:recorded'))
  35. end)
  36. it('gives the correct reg_recorded()', function()
  37. source_vim [[
  38. let g:recorded = 'a'
  39. let g:recording = ''
  40. autocmd RecordingLeave * let g:recording = reg_recording()
  41. autocmd RecordingLeave * let g:recorded = reg_recorded()
  42. call feedkeys("qqyyq", 'xt')
  43. ]]
  44. eq('q', eval 'g:recording')
  45. eq('', eval 'g:recorded')
  46. eq('q', eval 'reg_recorded()')
  47. end)
  48. it('populates v:event', function()
  49. source_vim [[
  50. let g:regname = ''
  51. let g:regcontents = ''
  52. autocmd RecordingLeave * let g:regname = v:event.regname
  53. autocmd RecordingLeave * let g:regcontents = v:event.regcontents
  54. call feedkeys("qqyyq", 'xt')
  55. ]]
  56. eq('q', eval 'g:regname')
  57. eq('yy', eval 'g:regcontents')
  58. end)
  59. it('resets v:event', function()
  60. source_vim [[
  61. autocmd RecordingLeave * let g:event = v:event
  62. call feedkeys("qqyyq", 'xt')
  63. ]]
  64. eq(0, eval 'len(v:event)')
  65. end)
  66. end)