tabnew_spec.lua 799 B

12345678910111213141516171819202122232425262728
  1. local helpers = require('test.functional.helpers')(after_each)
  2. local clear = helpers.clear
  3. local command = helpers.command
  4. local eq = helpers.eq
  5. local eval = helpers.eval
  6. describe('autocmd TabNew', function()
  7. before_each(clear)
  8. it('matches when opening any new tab', function()
  9. command('autocmd! TabNew * let g:test = "tabnew:".tabpagenr().":".bufnr("")')
  10. command('tabnew')
  11. eq('tabnew:2:1', eval('g:test'))
  12. command('tabnew test.x')
  13. eq('tabnew:3:2', eval('g:test'))
  14. end)
  15. it('matches when opening a new tab for FILE', function()
  16. command('let g:test = "foo"')
  17. command('autocmd! TabNew Xtest-tabnew let g:test = "bar"')
  18. command('tabnew Xtest-tabnewX')
  19. eq('foo', eval('g:test'))
  20. command('tabnew Xtest-tabnew')
  21. eq('bar', eval('g:test'))
  22. end)
  23. end)