robin/laufey

git clone https://git.robinwobin.dev/robin/laufey

zeertzjqvim-patch:9.1.1870: :Tutor may not work as expected (#36343)fb6fd17f26

master
1.4 KiB55 linesraw
1" Test for the new-tutor plugin
2
3source screendump.vim
4source check.vim
5source script_util.vim
6
7func SetUp()
8  set nocompatible
9  runtime plugin/tutor.vim
10endfunc
11
12func Test_auto_enable_interactive()
13  Tutor
14  call assert_equal('nowrite', &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
21
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
39
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