aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--test/functional/autocmd/tabnew_spec.lua44
1 files changed, 25 insertions, 19 deletions
diff --git a/test/functional/autocmd/tabnew_spec.lua b/test/functional/autocmd/tabnew_spec.lua
index 5ab504889b..aaf9db0a99 100644
--- a/test/functional/autocmd/tabnew_spec.lua
+++ b/test/functional/autocmd/tabnew_spec.lua
@@ -1,22 +1,28 @@
local helpers = require('test.functional.helpers')
-local clear, nvim, eq = helpers.clear, helpers.nvim, helpers.eq
-describe('TabNew', function()
- setup(clear)
- describe('au TabNew', function()
- describe('with * as <afile>', function()
- it('matches when opening any new tab', function()
- nvim('command', 'au! TabNew * echom "tabnew:".tabpagenr().":".bufnr("")')
- eq("\ntabnew:2:1", nvim('command_output', 'tabnew'))
- eq("\ntabnew:3:2\n\"test.x\" [New File]", nvim('command_output', 'tabnew test.x'))
- end)
- end)
- describe('with FILE as <afile>', function()
- it('matches when opening a new tab for FILE', function()
- local tmp_path = nvim('eval', 'tempname()')
- nvim('command', 'au! TabNew '..tmp_path..' echom "tabnew:match"')
- eq("\ntabnew:4:3\ntabnew:match\n\""..tmp_path.."\" [New File]", nvim('command_output', 'tabnew '..tmp_path))
- end)
- end)
- end)
+local clear = helpers.clear
+local command = helpers.command
+local eq = helpers.eq
+local eval = helpers.eval
+
+describe('autocmd TabNew', function()
+ before_each(clear)
+
+ it('matches when opening any new tab', function()
+ command('autocmd! TabNew * let g:test = "tabnew:".tabpagenr().":".bufnr("")')
+ command('tabnew')
+ eq('tabnew:2:1', eval('g:test'))
+ command('tabnew test.x')
+ eq('tabnew:3:2', eval('g:test'))
+ end)
+
+ it('matches when opening a new tab for FILE', function()
+ local tmp_path = helpers.funcs.tempname()
+ command('let g:test = "foo"')
+ command('autocmd! TabNew ' .. tmp_path .. ' let g:test = "bar"')
+ command('tabnew ' .. tmp_path ..'X')
+ eq('foo', eval('g:test'))
+ command('tabnew ' .. tmp_path)
+ eq('bar', eval('g:test'))
+ end)
end)