Bram Moolenaar | 343b8c0 | 2017-02-17 12:04:56 +0100 | [diff] [blame] | 1 | " Tests for :help |
| 2 | |
| 3 | func Test_help_restore_snapshot() |
| 4 | help |
| 5 | set buftype= |
| 6 | help |
| 7 | edit x |
| 8 | help |
| 9 | helpclose |
| 10 | endfunc |
Bram Moolenaar | 751ba61 | 2017-03-16 22:26:44 +0100 | [diff] [blame] | 11 | |
| 12 | func Test_help_errors() |
| 13 | call assert_fails('help doesnotexist', 'E149:') |
| 14 | call assert_fails('help!', 'E478:') |
Bram Moolenaar | a4f99f5 | 2017-08-26 16:25:32 +0200 | [diff] [blame] | 15 | |
| 16 | new |
| 17 | set keywordprg=:help |
| 18 | call setline(1, " ") |
| 19 | call assert_fails('normal VK', 'E349:') |
| 20 | bwipe! |
| 21 | endfunc |
| 22 | |
| 23 | func Test_help_keyword() |
| 24 | new |
| 25 | set keywordprg=:help |
| 26 | call setline(1, " Visual ") |
| 27 | normal VK |
| 28 | call assert_match('^Visual mode', getline('.')) |
| 29 | call assert_equal('help', &ft) |
| 30 | close |
| 31 | bwipe! |
Bram Moolenaar | 751ba61 | 2017-03-16 22:26:44 +0100 | [diff] [blame] | 32 | endfunc |
Bram Moolenaar | 35c5e81 | 2017-12-09 21:10:13 +0100 | [diff] [blame] | 33 | |
| 34 | func Test_help_local_additions() |
| 35 | call mkdir('Xruntime/doc', 'p') |
| 36 | call writefile(['*mydoc.txt* my awesome doc'], 'Xruntime/doc/mydoc.txt') |
| 37 | call writefile(['*mydoc-ext.txt* my extended awesome doc'], 'Xruntime/doc/mydoc-ext.txt') |
| 38 | let rtp_save = &rtp |
| 39 | set rtp+=./Xruntime |
| 40 | help |
| 41 | 1 |
| 42 | call search('mydoc.txt') |
| 43 | call assert_equal('|mydoc.txt| my awesome doc', getline('.')) |
| 44 | 1 |
| 45 | call search('mydoc-ext.txt') |
| 46 | call assert_equal('|mydoc-ext.txt| my extended awesome doc', getline('.')) |
| 47 | close |
| 48 | |
| 49 | call delete('Xruntime', 'rf') |
| 50 | let &rtp = rtp_save |
| 51 | endfunc |