005_bufleave_delete_buffer_spec.lua 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. -- Test for autocommand that deletes the current buffer on BufLeave event.
  2. -- Also test deleting the last buffer, should give a new, empty buffer.
  3. local n = require('test.functional.testnvim')()
  4. local clear, feed, insert = n.clear, n.feed, n.insert
  5. local command, expect = n.command, n.expect
  6. local poke_eventloop = n.poke_eventloop
  7. describe('test5', function()
  8. setup(clear)
  9. -- luacheck: ignore 621 (Indentation)
  10. it('is working', function()
  11. insert([[
  12. start of test file Xxx
  13. vim: set noai :
  14. this is a test
  15. this is a test
  16. this is a test
  17. this is a test
  18. end of test file Xxx]])
  19. command('w! Xxx0')
  20. command('au BufLeave Xxx bwipe')
  21. command('/start of')
  22. -- Write test file Xxx.
  23. command('.,/end of/w! Xxx')
  24. -- Split to Xxx.
  25. command('sp Xxx')
  26. -- Delete buffer Xxx, now we're back here.
  27. command('bwipe')
  28. feed('G?this is a<cr>')
  29. feed('othis is some more text<esc>')
  30. poke_eventloop()
  31. -- Append some text to this file.
  32. -- Write current file contents.
  33. command('?start?,$yank A')
  34. -- Delete current buffer, get an empty one.
  35. command('bwipe!')
  36. -- Append an extra line to the output register.
  37. feed('ithis is another test line<esc>:yank A<cr>')
  38. poke_eventloop()
  39. -- Output results
  40. command('%d')
  41. command('0put a')
  42. command('$d')
  43. -- Assert buffer contents.
  44. expect([[
  45. start of test file Xxx
  46. vim: set noai :
  47. this is a test
  48. this is a test
  49. this is a test
  50. this is a test
  51. this is some more text
  52. end of test file Xxx
  53. this is another test line]])
  54. end)
  55. teardown(function()
  56. os.remove('Xxx')
  57. os.remove('Xxx0')
  58. end)
  59. end)