functests: Refactor 009_bufleave_autocommand_spec

It was not testing anything actually: the `e yy` command simply failed because 
of unsaved changes, BufLeave never run thus.
This commit is contained in:
ZyX 2017-04-08 21:46:30 +03:00
parent cd0a436622
commit 1ef98b34b3

View File

@ -1,19 +1,27 @@
-- Test for Bufleave autocommand that deletes the buffer we are about to edit.
local helpers = require('test.functional.helpers')(after_each)
local clear, insert = helpers.clear, helpers.insert
local execute, expect = helpers.execute, helpers.expect
local eq = helpers.eq
local clear = helpers.clear
local meths = helpers.meths
local expect = helpers.expect
local command = helpers.command
local exc_exec = helpers.exc_exec
local curbufmeths = helpers.curbufmeths
describe('BufLeave autocommand', function()
setup(clear)
it('is working', function()
insert([[
start of test file xx
end of test file xx]])
meths.set_option('hidden', true)
curbufmeths.set_lines(0, 1, false, {
'start of test file xx',
'end of test file xx'})
execute('au BufLeave * bwipe yy')
execute('e yy')
command('autocmd BufLeave * bwipeout yy')
eq('Vim(edit):E143: Autocommands unexpectedly deleted new buffer yy',
exc_exec('edit yy'))
expect([[
start of test file xx