tabnew_spec.lua 795 B

1234567891011121314151617181920212223242526272829
  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 eq = t.eq
  6. local eval = n.eval
  7. describe('autocmd TabNew', function()
  8. before_each(clear)
  9. it('matches when opening any new tab', function()
  10. command('autocmd! TabNew * let g:test = "tabnew:".tabpagenr().":".bufnr("")')
  11. command('tabnew')
  12. eq('tabnew:2:1', eval('g:test'))
  13. command('tabnew test.x')
  14. eq('tabnew:3:2', eval('g:test'))
  15. end)
  16. it('matches when opening a new tab for FILE', function()
  17. command('let g:test = "foo"')
  18. command('autocmd! TabNew Xtest-tabnew let g:test = "bar"')
  19. command('tabnew Xtest-tabnewX')
  20. eq('foo', eval('g:test'))
  21. command('tabnew Xtest-tabnew')
  22. eq('bar', eval('g:test'))
  23. end)
  24. end)