005_bufleave_delete_buffer_spec.lua (1732B)
1 -- Test for autocommand that deletes the current buffer on BufLeave event. 2 -- Also test deleting the last buffer, should give a new, empty buffer. 3 4 local n = require('test.functional.testnvim')() 5 6 local clear, feed, insert = n.clear, n.feed, n.insert 7 local command, expect = n.command, n.expect 8 local poke_eventloop = n.poke_eventloop 9 10 describe('test5', function() 11 setup(clear) 12 13 -- luacheck: ignore 621 (Indentation) 14 it('is working', function() 15 insert([[ 16 start of test file Xxx 17 vim: set noai : 18 this is a test 19 this is a test 20 this is a test 21 this is a test 22 end of test file Xxx]]) 23 24 command('w! Xxx0') 25 command('au BufLeave Xxx bwipe') 26 command('/start of') 27 28 -- Write test file Xxx. 29 command('.,/end of/w! Xxx') 30 31 -- Split to Xxx. 32 command('sp Xxx') 33 34 -- Delete buffer Xxx, now we're back here. 35 command('bwipe') 36 feed('G?this is a<cr>') 37 feed('othis is some more text<esc>') 38 poke_eventloop() 39 40 -- Append some text to this file. 41 42 -- Write current file contents. 43 command('?start?,$yank A') 44 45 -- Delete current buffer, get an empty one. 46 command('bwipe!') 47 -- Append an extra line to the output register. 48 feed('ithis is another test line<esc>:yank A<cr>') 49 poke_eventloop() 50 51 -- Output results 52 command('%d') 53 command('0put a') 54 command('$d') 55 56 -- Assert buffer contents. 57 expect([[ 58 start of test file Xxx 59 vim: set noai : 60 this is a test 61 this is a test 62 this is a test 63 this is a test 64 this is some more text 65 end of test file Xxx 66 this is another test line]]) 67 end) 68 69 teardown(function() 70 os.remove('Xxx') 71 os.remove('Xxx0') 72 end) 73 end)