blob: 5c3dcd949dfecddbfe7f11bfc57d01797834c977 [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
Phạm Bình Ana541f1d2025-06-01 18:58:09 +02004source script_util.vim
5
Phạm Bình An13bea582025-05-12 20:39:24 +02006func SetUp()
7 set nocompatible
8 runtime plugin/tutor.vim
9endfunc
10
11func 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)
19endfunc
Phạm Bình Ane8302da2025-05-22 22:53:28 +020020
21func 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
37endfunc
Phạm Bình Ana541f1d2025-06-01 18:58:09 +020038
39func 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)
54endfunc