summaryrefslogtreecommitdiff
path: root/mnv/src/testdir/test_plugin_tutor.mnv
blob: 1253fe4423e8d10647b176ae419d41216acf99ba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
" Test for the new-tutor plugin

source util/screendump.mnv
source util/script_util.mnv

func SetUp()
  set nocompatible
  runtime plugin/tutor.mnv
endfunc

func Test_auto_enable_interactive()
  Tutor
  call assert_equal('nowrite', &buftype)
  call assert_match('tutor#EnableInteractive', b:undo_ftplugin)

  edit Xtutor/Xtest.tutor
  call assert_true(empty(&buftype))
  call assert_match('tutor#EnableInteractive', b:undo_ftplugin)
endfunc

func Test_tutor_link()
  let tutor_files = globpath($MNVRUNTIME, 'tutor/**/*.tutor', 0, 1)
  let pattern = '\[.\{-}@tutor:\zs[^)\]]*\ze[)\]]'

  for tutor_file in tutor_files
    let lang = fnamemodify(tutor_file, ':h:t')
    if lang == 'tutor'
      let lang = 'en'
    endif

    let text = readfile(tutor_file)
    let links = matchstrlist(text, pattern)->map({_, v -> v.text})
    for link in links
      call assert_true(tutor#GlobTutorials(link, lang)->len() > 0)
    endfor
  endfor
endfunc

func Test_mark()
  CheckScreendump
  call writefile([
  \ 'set nocompatible',
  \ 'runtime plugin/tutor.mnv',
  \ 'Tutor tutor',
  \ 'set statusline=',
  \ ], 'Xtest_plugin_tutor_mark', 'D')
  let buf = RunMNVInTerminal('-S Xtest_plugin_tutor_mark', {'rows': 20, 'cols': 78})
  call term_sendkeys(buf, ":240\<CR>")
  call WaitForAssert({-> assert_match('Bot$', term_getline(buf, 20))})
  call VerifyScreenDump(buf, 'Test_plugin_tutor_mark_1', {})

  " clean up
  call StopMNVInTerminal(buf)
endfunc