robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
f907614088
master
1local n =require ( 'test.functional.testnvim' )() 2local t =require ( 'test.testutil' ) 3local Screen =require ( 'test.functional.ui.screen' ) 4 5local describe , it , before_each =t . describe , t . it , t . before_each 6local command =n . command 7local clear , feed , feed_command =n . clear , n . feed , n . feed_command 8local exec =n . exec 9 10describe ( ':drop' , function () 11local screen 12 13before_each ( function () 14clear () 15screen =Screen . new ( 35 , 10 ) 16screen : set_default_attr_ids ( { 17[ 0 ] ={ bold =true , foreground =Screen . colors . Blue } , 18[ 1 ] ={ bold =true , reverse =true } , 19[ 2 ] ={ reverse =true } , 20[ 3 ] ={ bold =true } , 21} ) 22command ( 'set nohidden laststatus=2 shortmess-=F' ) 23end ) 24 25it ( 'works like :e when called with only one window open' , function () 26feed_command ( 'drop tmp1.vim' ) 27screen : expect ( [[ 28^ | 29{0:~ }|*7 30{1:tmp1.vim }| 31"tmp1.vim" [New] | 32]] ) 33end ) 34 35it ( 'switches to an open window showing the buffer' , function () 36feed_command ( 'edit tmp1' ) 37feed_command ( 'vsplit' ) 38feed_command ( 'edit tmp2' ) 39feed_command ( 'drop tmp1' ) 40screen : expect ( [[ 41│^ | 42{0:~ }│{0:~ }|*7 43{2:tmp2 }{1:tmp1 }| 44"tmp1" [New] | 45]] ) 46end ) 47 48it ( "splits off a new window when a buffer can't be abandoned" , function () 49feed_command ( 'edit tmp1' ) 50feed_command ( 'vsplit' ) 51feed_command ( 'edit tmp2' ) 52feed ( 'iABC<esc>' ) 53feed_command ( 'drop tmp3' ) 54screen : expect ( [[ 55^ │ | 56{0:~ }│{0:~ }|*3 57{1:tmp3 }│{0:~ }| 58ABC │{0:~ }| 59{0:~ }│{0:~ }|*2 60{2:tmp2 [+] tmp1 }| 61"tmp3" [New] | 62]] ) 63end ) 64 65-- oldtest: Test_drop_modified_file() 66it ( 'does not cause E37 with modified same file' , function () 67exec ( [[ 68edit Xdrop_modified.txt 69call setline(1, 'The quick brown fox jumped over the lazy dogs') 70]] ) 71feed_command ( 'drop Xdrop_modified.txt' ) 72screen : expect ( [[ 73^The quick brown fox jumped over the| 74lazy dogs | 75{0:~ }|*6 76{1:Xdrop_modified.txt [+] }| 77:drop Xdrop_modified.txt | 78]] ) 79end ) 80 81it ( 'jumps to line number when passed +line' , function () 82exec ( [[ 83edit Xdrop_line.txt 84call append(0, "I just miss doing art. Don't you?") 85call append(1, "It is not so hard as we have supposed.") 86call append(2, "We are propelled by disaster. We are moving swiftly.") 87]] ) 88feed_command ( 'drop +2 Xdrop_line.txt' ) 89screen : expect ( [[ 90I just miss doing art. Don't you? | 91^It is not so hard as we have suppos| 92ed. | 93We are propelled by disaster. We ar| 94e moving swiftly. | 95| 96{0:~ }|*2 97{1:Xdrop_line.txt [+] }| 98:drop +2 Xdrop_line.txt | 99]] ) 100end ) 101end )