diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2017-01-12 03:19:30 +0100 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2017-01-13 01:17:11 +0100 |
commit | cc7f1aba46716cf509ca784840d6e77f7bfb2318 (patch) | |
tree | 3063661f29d00197fe3c30338d8e25f778d64954 | |
parent | b5e8e2f20d6e0c3d0201f577254d54ae5913a7d2 (diff) | |
download | rneovim-cc7f1aba46716cf509ca784840d6e77f7bfb2318.tar.gz rneovim-cc7f1aba46716cf509ca784840d6e77f7bfb2318.tar.bz2 rneovim-cc7f1aba46716cf509ca784840d6e77f7bfb2318.zip |
test: BufEnter
-rw-r--r-- | test/functional/autocmd/bufenter_spec.lua | 35 |
1 files changed, 35 insertions, 0 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) |