robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
f907614088
master
1local t =require ( 'test.testutil' ) 2local n =require ( 'test.functional.testnvim' )() 3 4local tt =require ( 'test.functional.testterm' ) 5local describe , it , before_each , after_each =t . describe , t . it , t . before_each , t . after_each 6local ok =t . ok 7 8if t . skip ( t . is_os ( 'win' )) then 9return 10end 11 12describe ( 'api' , function () 13local screen 14local socket_name ='./Xtest_functional_api.sock' 15 16before_each ( function () 17n . clear () 18os . remove ( socket_name ) 19screen =tt . setup_child_nvim ( { 20'-u' , 21'NONE' , 22'-i' , 23'NONE' , 24'--cmd' , 25'colorscheme vim' , 26'--cmd' , 27n . nvim_set .. ' notermguicolors' , 28} ) 29end ) 30after_each ( function () 31os . remove ( socket_name ) 32end ) 33 34it ( 'qa! RPC request during insert-mode' , function () 35screen : expect ( [[ 36^ | 37{100:~ }|*4 38| 39{5:-- TERMINAL --} | 40]] ) 41 42-- Start the socket from the child nvim. 43tt . feed_data ( ":echo serverstart('" .. socket_name .. "')\n" ) 44 45-- Wait for socket creation. 46screen : expect ( [[ 47^ | 48{100:~ }|*4 49]] .. socket_name .. [[ | 50{5:-- TERMINAL --} | 51]] ) 52 53local socket_session1 =n . connect ( socket_name ) 54local socket_session2 =n . connect ( socket_name ) 55 56tt . feed_data ( 'i[tui] insert-mode' ) 57-- Wait for stdin to be processed. 58screen : expect ( [[ 59[tui] insert-mode^ | 60{100:~ }|*4 61{5:-- INSERT --} | 62{5:-- TERMINAL --} | 63]] ) 64 65ok (( socket_session1 : request ( 'nvim_ui_attach' , 42 , 6 , { rgb =true } ))) 66ok (( socket_session2 : request ( 'nvim_ui_attach' , 25 , 30 , { rgb =true } ))) 67 68socket_session1 : notify ( 'nvim_input' , '\n[socket 1] this is more than 25 columns' ) 69socket_session2 : notify ( 'nvim_input' , '\n[socket 2] input' ) 70 71screen : expect ( [[ 72[tui] insert-mode | 73[socket 1] this is more t | 74han 25 columns | 75[socket 2] input^ | 76{100:~ } | 77{5:-- INSERT --} | 78{5:-- TERMINAL --} | 79]] ) 80 81socket_session1 : request ( 'nvim_command' , 'qa!' ) 82end ) 83end )