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