diff options
Diffstat (limited to 'test/functional/autocmd')
-rw-r--r-- | test/functional/autocmd/bufenter_spec.lua | 35 | ||||
-rw-r--r-- | test/functional/autocmd/tabnew_spec.lua | 9 | ||||
-rw-r--r-- | test/functional/autocmd/tabnewentered_spec.lua | 8 |
3 files changed, 41 insertions, 11 deletions
diff --git a/test/functional/autocmd/bufenter_spec.lua b/test/functional/autocmd/bufenter_spec.lua new file mode 100644 index 0000000000..ccbcdf5c5e --- /dev/null +++ b/test/functional/autocmd/bufenter_spec.lua @@ -0,0 +1,35 @@ +local helpers = require('test.functional.helpers')(after_each) + +local clear = helpers.clear +local command = helpers.command +local eq = helpers.eq +local eval = helpers.eval +local execute = helpers.execute +local request = helpers.request +local source = helpers.source + +describe('autocmd BufEnter', function() + before_each(clear) + + it("triggered by nvim_command('edit <dir>')", function() + command("autocmd BufEnter * if isdirectory(expand('<afile>')) | let g:dir_bufenter = 1 | endif") + request("nvim_command", "split .") + eq(1, eval("exists('g:dir_bufenter')")) -- Did BufEnter for the directory. + eq(2, eval("bufnr('%')")) -- Switched to the dir buffer. + end) + + it('triggered by "try|:split <dir>|endtry" in a function', function() + command("autocmd BufEnter * if isdirectory(expand('<afile>')) | let g:dir_bufenter = 1 | endif") + source([[ + function! Test() + try + exe 'split .' + catch + endtry + endfunction + ]]) + execute("call Test()") + eq(1, eval("exists('g:dir_bufenter')")) -- Did BufEnter for the directory. + eq(2, eval("bufnr('%')")) -- Switched to the dir buffer. + end) +end) diff --git a/test/functional/autocmd/tabnew_spec.lua b/test/functional/autocmd/tabnew_spec.lua index 2148b21832..ad40954f76 100644 --- a/test/functional/autocmd/tabnew_spec.lua +++ b/test/functional/autocmd/tabnew_spec.lua @@ -5,8 +5,6 @@ local command = helpers.command local eq = helpers.eq local eval = helpers.eval -if helpers.pending_win32(pending) then return end - describe('autocmd TabNew', function() before_each(clear) @@ -19,12 +17,11 @@ describe('autocmd TabNew', function() 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') + command('autocmd! TabNew Xtest-tabnew let g:test = "bar"') + command('tabnew Xtest-tabnewX') eq('foo', eval('g:test')) - command('tabnew ' .. tmp_path) + command('tabnew Xtest-tabnew') eq('bar', eval('g:test')) end) end) diff --git a/test/functional/autocmd/tabnewentered_spec.lua b/test/functional/autocmd/tabnewentered_spec.lua index f033bd5fe4..bdbe677132 100644 --- a/test/functional/autocmd/tabnewentered_spec.lua +++ b/test/functional/autocmd/tabnewentered_spec.lua @@ -1,8 +1,6 @@ local helpers = require('test.functional.helpers')(after_each) local clear, nvim, eq = helpers.clear, helpers.nvim, helpers.eq -if helpers.pending_win32(pending) then return end - describe('TabNewEntered', function() describe('au TabNewEntered', function() describe('with * as <afile>', function() @@ -15,9 +13,9 @@ describe('TabNewEntered', function() 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! TabNewEntered '..tmp_path..' echom "tabnewentered:match"') - eq("\n\""..tmp_path.."\" [New File]\ntabnewentered:4:4\ntabnewentered:match", nvim('command_output', 'tabnew '..tmp_path)) + nvim('command', 'au! TabNewEntered Xtest-tabnewentered echom "tabnewentered:match"') + eq('\n"Xtest-tabnewentered" [New File]\ntabnewentered:4:4\ntabnewentered:match', + nvim('command_output', 'tabnew Xtest-tabnewentered')) end) end) describe('with CTRL-W T', function() |