robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
f907614088
master
1local t =require ( 'test.testutil' ) 2local n =require ( 'test.functional.testnvim' )() 3local tt =require ( 'test.functional.testterm' ) 4 5local describe , it , before_each , teardown =t . describe , t . it , t . before_each , t . teardown 6local clear =n . clear 7local feed_data =tt . feed_data 8 9describe ( 'autoread TUI FocusGained/FocusLost' , function () 10local f1 ='xtest-foo' 11local screen 12 13before_each ( function () 14clear () 15screen =tt . setup_child_nvim ( { 16'-u' , 17'NONE' , 18'-i' , 19'NONE' , 20'--cmd' , 21'colorscheme vim' , 22'--cmd' , 23'set noswapfile noshowcmd noruler notermguicolors' , 24} ) 25end ) 26 27teardown ( function () 28os . remove ( f1 ) 29end ) 30 31it ( 'external file change' , function () 32local path =f1 33local expected_addition =[[ 34line 1 35line 2 36line 3 37line 4 38]] 39 40t . write_file ( path , '' ) 41local atime =os . time () - 10 42vim . uv . fs_utime ( path , atime , atime ) 43 44screen : expect ( [[ 45^ | 46{100:~ }|*3 47{3:[No Name] }| 48| 49{5:-- TERMINAL --} | 50]] ) 51n . feed ( ':edit ' .. path .. '<CR>' ) 52screen : expect ( [[ 53^ | 54{100:~ }|*3 55{3:xtest-foo }| 56:edit xtest-foo | 57{5:-- TERMINAL --} | 58]] ) 59feed_data ( '\027[O' ) 60feed_data ( '\027[O' ) 61screen : expect_unchanged () 62 63t . write_file ( path , expected_addition ) 64 65feed_data ( '\027[I' ) 66 67screen : expect ( [[ 68^line 1 | 69line 2 | 70line 3 | 71line 4 | 72{3:xtest-foo }| 73:edit xtest-foo | 74{5:-- TERMINAL --} | 75]] ) 76end ) 77end )