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