Create a function fo reload the plugin. Fix setting of mediwiki syntax.

Also adds a few additional link creation tests.
This commit is contained in:
Rane Brown 2019-07-17 07:13:36 -06:00
parent 86cad979e5
commit e68592b8ef
4 changed files with 81 additions and 12 deletions

View File

@ -5,6 +5,11 @@ Given vimwiki (Text that is not a wikilink):
www.google.com
https://www.google.com
multiple words
let's
let's
file.wiki
file.md
file.mw
Execute (Set syntax to default):
call SetSyntax('default')
@ -20,12 +25,28 @@ Do (Create links default syntax):
j
v$
\<Enter>
j
v$
\<Enter>
j
\<Enter>
j
\<Enter>
j
\<Enter>
j
\<Enter>
Expect (Vimwiki links):
[[test]]
[[www.google.com]]
[[https://www.google.com]]
[[multiple words]]
[[let's]]
[[let]]'s
[[file.wiki]]
[[file.md]]
[[file.mw]]
Execute (Set syntax to markdown):
call SetSyntax('markdown')
@ -41,15 +62,31 @@ Do (Create links markdown syntax):
j
v$
\<Enter>
j
v$
\<Enter>
j
\<Enter>
j
\<Enter>
j
\<Enter>
j
\<Enter>
Expect (Markdown links):
[test](test)
[www.google.com](www.google.com)
[https://www.google.com](https://www.google.com)
[multiple words](multiple words)
[let's](let's)
[let](let)'s
[file wiki](file.wiki)
[file](file.md)
[file mw](file.mw)
Execute (Set syntax to mediawiki):
call SetSyntax('mediawiki')
call SetSyntax('media')
Do (Create links mediawiki syntax):
\<Enter>
@ -62,11 +99,27 @@ Do (Create links mediawiki syntax):
j
v$
\<Enter>
j
v$
\<Enter>
j
\<Enter>
j
\<Enter>
j
\<Enter>
j
\<Enter>
Expect (Mediawiki links):
[[test]]
[[www.google.com]]
[[https://www.google.com]]
[[multiple words]]
[[let's]]
[[let]]'s
[[file.wiki]]
[[file.md]]
[[file.mw]]
Include: vader_teardown.vader

View File

@ -1,13 +1,8 @@
Before (Setup):
Include: vader_setup.vader
Execute (Set fold method):
let g:vimwiki_folding = 'expr:quick'
" clear mappings so plugin can be reloaded
" this is needed if running manually multiple times
nmapclear
" reload the plugin to set the fold method
unlet g:loaded_vimwiki
source plugin/vimwiki.vim
call ReloadVimwiki()
Execute (Expect < 0.5 second delay: Issue #580):
" prep
@ -29,3 +24,9 @@ Execute (Expect < 0.5 second delay: Issue #580):
" verify
Log 'Elapsed time = ' . string(end)
Assert end < 0.5, 'Took longer than expected: ' . string(end) . ' seconds'
Execute (Reset variables):
let g:vimwiki_folding = ''
call ReloadVimwiki()
Include: vader_teardown.vader

View File

@ -9,10 +9,11 @@ Before (Define functions):
let ext = 'wiki'
elseif a:vw_syn ==# 'markdown'
let ext = 'md'
elseif a:vw_syn ==# 'mediawiki'
elseif a:vw_syn ==# 'media'
let ext = 'mw'
else
Log 'Inavlid syntax ' . a:vw_syn . ' in SetSyntax()'
Log 'ERROR: Invalid syntax "' . a:vw_syn . '" in SetSyntax()'
Log 'NOTE: function only accepts "media" for setting mediawiki syntax'
return
endif
let path = expand('%:p:h')
@ -23,4 +24,17 @@ Before (Define functions):
call vimwiki#vars#add_temporary_wiki(new_temp_wiki_settings)
call vimwiki#vars#set_bufferlocal('wiki_nr', g:wiki_nr)
let g:wiki_nr += 1
" verify syntax was set correctly
Assert vimwiki#vars#get_wikilocal('syntax') ==# a:vw_syn, 'ERROR: Vimwiki syntax not set correctly.'
endfunction
" reload plugin to change settings
function! ReloadVimwiki()
" clear mappings so plugin can be reloaded
" this is needed if running manually multiple times
nmapclear
unlet g:loaded_vimwiki
source plugin/vimwiki.vim
endfunction

View File

@ -1,3 +1,4 @@
Execute (Cleanup):
delfunction SetSyntax
delfunction ReloadVimwiki
unlet g:wiki_nr