054_buffer_local_autocommands_spec.lua 907 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. -- Some tests for buffer-local autocommands
  2. local n = require('test.functional.testnvim')()
  3. local clear = n.clear
  4. local expect = n.expect
  5. local command = n.command
  6. local fname = 'Xtest-functional-legacy-054'
  7. describe('BufLeave <buffer>', function()
  8. setup(clear)
  9. it('is working', function()
  10. command('write! ' .. fname)
  11. command('autocmd BufLeave <buffer> normal! Ibuffer-local autocommand')
  12. command('autocmd BufLeave <buffer> update')
  13. -- Here, autocommand for xx shall append a line
  14. -- But autocommand shall not apply to buffer named <buffer>
  15. command('edit somefile')
  16. -- Here, autocommand shall be auto-deleted
  17. command('bwipeout ' .. fname)
  18. -- Nothing shall be written
  19. command('edit ' .. fname)
  20. command('edit somefile')
  21. command('edit ' .. fname)
  22. expect('buffer-local autocommand')
  23. end)
  24. teardown(function()
  25. os.remove(fname)
  26. end)
  27. end)