Basic tests for creating links

This commit is contained in:
Rane Brown 2019-07-14 21:50:22 -06:00
parent fb7d2881d7
commit d536fa1117
3 changed files with 101 additions and 0 deletions

72
test/link_creation.vader Normal file
View File

@ -0,0 +1,72 @@
Include: vader_setup.vader
Given vimwiki (Text that is not a wikilink):
test
www.google.com
https://www.google.com
multiple words
Execute (Set syntax to default):
call SetSyntax('default')
Do (Create links default syntax):
\<Enter>
j
v$
\<Enter>
j
v$
\<Enter>
j
v$
\<Enter>
Expect (Vimwiki links):
[[test]]
[[www.google.com]]
[[https://www.google.com]]
[[multiple words]]
Execute (Set syntax to markdown):
call SetSyntax('markdown')
Do (Create links markdown syntax):
\<Enter>
j
v$
\<Enter>
j
v$
\<Enter>
j
v$
\<Enter>
Expect (Markdown links):
[test](test)
[www.google.com](www.google.com)
[https://www.google.com](https://www.google.com)
[multiple words](multiple words)
Execute (Set syntax to mediawiki):
call SetSyntax('mediawiki')
Do (Create links mediawiki syntax):
\<Enter>
j
v$
\<Enter>
j
v$
\<Enter>
j
v$
\<Enter>
Expect (Mediawiki links):
[[test]]
[[www.google.com]]
[[https://www.google.com]]
[[multiple words]]
Include: vader_teardown.vader

26
test/vader_setup.vader Normal file
View File

@ -0,0 +1,26 @@
Execute (Setup):
" assumes 3 registered wikis in vimrc
let g:wiki_nr = 3
Before (Define functions):
" change the syntax using a temporary wiki
function! SetSyntax(vw_syn)
if a:vw_syn ==# 'default'
let ext = 'wiki'
elseif a:vw_syn ==# 'markdown'
let ext = 'md'
elseif a:vw_syn ==# 'mediawiki'
let ext = 'mw'
else
Log 'Inavlid syntax ' . a:vw_syn . ' in SetSyntax()'
return
endif
let path = expand('%:p:h')
let new_temp_wiki_settings = {'path': path,
\ 'ext': ext,
\ 'syntax': a:vw_syn,
\ }
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
endfunction

View File

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