robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
fb6fd17f26
master
1" Test for the new-tutor plugin 2 3source screendump.vim 4source check.vim 5source script_util.vim 6 7func SetUp () 8set nocompatible 9runtime plugin/tutor.vim 10endfunc 11 12func Test_auto_enable_interactive () 13Tutor 14call assert_equal ( 'nowrite' , & buftype ) 15call assert_match ( 'tutor#EnableInteractive' , b: undo_ftplugin ) 16 17edit Xtutor/Xtest.tutor 18call assert_true ( empty ( & buftype )) 19call assert_match ( 'tutor#EnableInteractive' , b: undo_ftplugin ) 20endfunc 21 22func Test_tutor_link () 23let tutor_files = globpath ( $ VIMRUNTIME , 'tutor/**/*.tutor' , 0 , 1 ) 24let pattern = '\[.\{-}@tutor:\zs[^)\]]*\ze[)\]]' 25 26for tutor_file in tutor_files 27let lang = fnamemodify ( tutor_file , ':h:t' ) 28if lang == 'tutor' 29let lang = 'en' 30endif 31 32let text = readfile ( tutor_file ) 33let links = matchstrlist ( text , pattern ) ->map ({ _ , v ->v . text }) 34for link in links 35call assert_true ( tutor#GlobTutorials ( link , lang ) ->len () > 0 ) 36endfor 37endfor 38endfunc 39 40func Test_mark () 41CheckScreendump 42call writefile ([ 43 \'set nocompatible' , 44 \'runtime plugin/tutor.vim' , 45 \'Tutor tutor' , 46 \'set statusline=' , 47 \], 'Xtest_plugin_tutor_mark' , 'D' ) 48let buf = RunVimInTerminal ( '-S Xtest_plugin_tutor_mark' , { 'rows' : 20 , 'cols' : 78 }) 49call term_sendkeys ( buf , ":240\<CR>" ) 50call WaitForAssert ({ ->assert_match ( 'Bot$' , term_getline ( buf , 20 ))}) 51call VerifyScreenDump ( buf , 'Test_plugin_tutor_mark_1' , {}) 52 53" clean up 54call StopVimInTerminal ( buf ) 55endfunc