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