Tests: clean up tabnew_spec.lua

This commit is contained in:
Marco Hinz 2016-03-02 02:27:41 +01:00
parent 576c5f7b74
commit d9e631f1b5

View File

@ -1,22 +1,28 @@
local helpers = require('test.functional.helpers') local helpers = require('test.functional.helpers')
local clear, nvim, eq = helpers.clear, helpers.nvim, helpers.eq
describe('TabNew', function() local clear = helpers.clear
setup(clear) local command = helpers.command
describe('au TabNew', function() local eq = helpers.eq
describe('with * as <afile>', function() local eval = helpers.eval
describe('autocmd TabNew', function()
before_each(clear)
it('matches when opening any new tab', function() it('matches when opening any new tab', function()
nvim('command', 'au! TabNew * echom "tabnew:".tabpagenr().":".bufnr("")') command('autocmd! TabNew * let g:test = "tabnew:".tabpagenr().":".bufnr("")')
eq("\ntabnew:2:1", nvim('command_output', 'tabnew')) command('tabnew')
eq("\ntabnew:3:2\n\"test.x\" [New File]", nvim('command_output', 'tabnew test.x')) eq('tabnew:2:1', eval('g:test'))
command('tabnew test.x')
eq('tabnew:3:2', eval('g:test'))
end) end)
end)
describe('with FILE as <afile>', function()
it('matches when opening a new tab for FILE', function() it('matches when opening a new tab for FILE', function()
local tmp_path = nvim('eval', 'tempname()') local tmp_path = helpers.funcs.tempname()
nvim('command', 'au! TabNew '..tmp_path..' echom "tabnew:match"') command('let g:test = "foo"')
eq("\ntabnew:4:3\ntabnew:match\n\""..tmp_path.."\" [New File]", nvim('command_output', 'tabnew '..tmp_path)) command('autocmd! TabNew ' .. tmp_path .. ' let g:test = "bar"')
end) command('tabnew ' .. tmp_path ..'X')
end) eq('foo', eval('g:test'))
command('tabnew ' .. tmp_path)
eq('bar', eval('g:test'))
end) end)
end) end)