Merge tinmarino-dev_vader. Add new vader tests.

Adds tests for the commands:
VimwikiTOC, VimwikiGenerateLinks, VimwikiDiaryGenerateLinks,
VimwikiRebuildTags, VimwikiGenerateTags, VimwikiGoto

Add syntax tests, key mapping tests and table auto format tests.

New helper function in vader setup file.

The default wikis setup in the test vimrc are now mapped to the Docker
containers test user's home directory. The test user does not have
access to write to other locations.
This commit is contained in:
Rane Brown 2019-12-14 21:37:28 -07:00
parent 58331993c7
commit 36faec1de9
12 changed files with 1377 additions and 6 deletions

View File

@ -43,6 +43,15 @@ automatically run all tests for all installed vim versions. The vim/nvim
versions are parsed from the Dockerfile. This script will also run `Vint` for all versions are parsed from the Dockerfile. This script will also run `Vint` for all
plugin source files. For more information run `./run_tests.sh -h`. plugin source files. For more information run `./run_tests.sh -h`.
## Inside the container
* `$USER` -> `vimtest` : unprivileged => very hard to mess up things
* `$HOME` -> `/home/vimtest` : but it is readonly !
* `$PWD` -> `/testplugin` : mapped to vimwiki plugin root directory
For more information, read the [base docker image](https://github.com/tweekmonster/vim-testbed)
## Known Issues ## Known Issues
1. neovim v0.2.x does not work correctly with Vader output from the docker 1. neovim v0.2.x does not work correctly with Vader output from the docker

View File

@ -0,0 +1,108 @@
Include: vader_includes/vader_setup.vader
Execute (Copy Wiki's Resources):
Log "Start: Copy Resources"
call CopyResources()
# 1 VimwikiGenerateLinks
##########################
Execute (New Command):
Log "1. Testing VimwikiGenerateLinks"
set sw=4
AssertEqual 4, &sw
Given (Void):
Execute (Goto markdown resource wiki):
VimwikiIndex 2
AssertEqual $HOME . '/testmarkdown/index.md', expand('%')
Execute (Edit Test file / VimwikiGenerateLinks):
edit $HOME/testmarkdown/Test.md
AssertEqual $HOME . '/testmarkdown/Test.md', expand('%')
AssertEqual 'markdown', vimwiki#vars#get_wikilocal('syntax')
AssertEqual 1, vimwiki#vars#get_bufferlocal('wiki_nr')
VimwikiGenerateLinks
Expect (The links with a header):
# Generated Links
- [Buzz Bozz](buzz_bozz)
- [Test Wiki](index)
Do (Save Test.md && Re-GenerateLinks):
:edit $HOME/testmarkdown/Test.md\<CR>
:set bt=\<CR>
:write %\<CR>
:VimwikiGenerateLinks\<CR>
Expect (The links with a header with file Test):
# Generated Links
- [Generated Links](Test)
- [Buzz Bozz](buzz_bozz)
- [Test Wiki](index)
# 2 VimwikiDiaryGenerateLinks
#############################
Execute (New Command):
Log "2. Testing VimwikiDiaryGenerateLinks TODO"
set sw=4
AssertEqual 4, &sw
Do (Edit diary/2019-12-10):
:edit $HOME/testmarkdown/diary/2019-12-10.md\<CR>
iinformative content\<Esc>
:call WriteMe()\<CR>
Do (Edit and save diary/2019-07-13):
:edit $HOME/testmarkdown/diary/2019-07-13.md\<CR>
i# informative title\<Esc>
:call WriteMe()\<CR>
Do (Edit and save diary/2018-03-01):
:edit $HOME/testmarkdown/diary/2019-03-01.md\<CR>
:call WriteMe()\<CR>
Do (Edit diary.md && GenerateDiaryLinks):
:edit $HOME/testmarkdown/diary/diary.md\<CR>
:VimwikiDiaryGenerateLinks\<CR>
Expect (diary index generated):
# Diary
## 2019
### December
- [2019-12-10](2019-12-10)
### July
- [informative title](2019-07-13)
### March
- [2019-03-01](2019-03-01)
Execute (Clean):
Log "End: Clean"
call system("rm $HOME/testmarkdown/diary/2019-12-10.md")
call system("rm $HOME/testmarkdown/diary/2019-07-13.md")
call system("rm $HOME/testmarkdown/diary/2019-03-01.md")
call system("rm $HOME/testmarkdown/diary/diary.md")
Include: vader_includes/vader_teardown.vader
# vim: sw=2 ft=conf foldmethod=indent foldlevel=30 foldignore=

View File

@ -0,0 +1,75 @@
Include: vader_includes/vader_setup.vader
Execute (Copy Wiki's Resources):
Log "Start: Copy Resources"
call CopyResources()
# 1 VimwikiRebuildTags
######################
Execute (New Command):
Log "1 Testing VimwikiRebuildTags"
set sw=4
AssertEqual 4, &sw
Execute (Edit Test-Tag.md):
edit $HOME/testmarkdown/Test-Tag.md
AssertEqual $HOME . '/testmarkdown/Test-Tag.md', expand('%')
AssertEqual 'markdown', vimwiki#vars#get_wikilocal('syntax')
AssertEqual 1, vimwiki#vars#get_bufferlocal('wiki_nr')
Do (Add tag <- with `Do` trick to save file):
:edit $HOME/testmarkdown/Test-Tag.md\<CR>
:call append(0, ":test-tag:")\<CR>
:set bt=\<CR>
:write %\<CR>
:VimwikiRebuildTags\<CR>
Execute (Edit .vimwiki_tags):
edit $HOME/testmarkdown/.vimwiki_tags
AssertEqual $HOME . '/testmarkdown/.vimwiki_tags', expand('%')
AssertEqual 'markdown', vimwiki#vars#get_wikilocal('syntax')
AssertEqual 1, vimwiki#vars#get_bufferlocal('wiki_nr')
# Carefull, following 2 lines have tabs: `this is the way`
Expect (Tag file with test-tag):
!_TAG_FILE_SORTED 1
test-tag Test-Tag.md 1;" vimwiki:Test-Tag\tTest-Tag
# 2 VimwikiGenerateTags
#########################
Execute (New Command):
Log "2 Testing VimwikiGenerateTags TODO"
set sw=4
AssertEqual 4, &sw
Given (Void):
Do (Edit Test-Tag && GenerateTags):
:edit $HOME/testmarkdown/Test-Tag.md\<CR>
:call append(0, ':Tag:')\<Cr>
:call append(0, '')\<Cr>
:call append(0, 'Test Here')\<Cr>
:call append(0, '')\<Cr>
:call append(0, '# A header')\<Cr>
:call WriteMe()\<CR>
:VimwikiRebuildTags\<CR>
:VimwikiGenerateTags\<CR>
:Log "TODO give the expect block when VimwikigenerateTags is working"\<CR>
Execute (Clean Test-Tag and .vimwiki_tags):
Log "End: Clean"
call system("rm $HOME/testmarkdown/Test.md")
call system("rm $HOME/testmarkdown/.vimwiki_tags")
call system("rm $HOME/testmarkdown/Test-Tag.md")
call DeleteHiddenBuffers()
Include: vader_includes/vader_teardown.vader
# vim: sw=2 ft=conf foldmethod=indent foldlevel=30 foldignore=

29
test/command_goto.vader Normal file
View File

@ -0,0 +1,29 @@
Include: vader_includes/vader_setup.vader
Execute (Copy Wiki's Resources):
Log "Start: Copy Resources"
call CopyResources()
Execute (VimwikiGoto buzz_bozz && Assert):
VimwikiIndex 2
VimwikiGoto buzz_bozz
AssertEqual $HOME . '/testmarkdown/buzz_bozz.md', expand('%')
Do (VimwikiGoto <CR> buzz_bozz && Assert):
:VimwikiIndex 2\<CR>
:VimwikiGoto\<CR>
buzz_bozz\<CR>
:AssertEqual $HOME . '/testmarkdown/buzz_bozz.md', expand('%')\<CR>
Execute (:VimwikiGoto + Completion):
VimwikiIndex 2
AssertEqual $HOME . '/testmarkdown/index.md', expand('%')
let s_complete=vimwiki#base#get_globlinks_escaped()
Assert -1 != stridx(s_complete, 'buzz_bozz')
Include: vader_includes/vader_teardown.vader
# vim: sw=2 ft=conf foldmethod=indent foldlevel=30 foldignore=

148
test/command_toc.vader Normal file
View File

@ -0,0 +1,148 @@
Include: vader_includes/vader_setup.vader
Execute (Reset TOC header to default):
let g:vimwiki_global_vars['toc_header'] = "Contents"
Given vimwiki (Headings):
# Header 1
random text
## Header 1.1
random text
### Header 1.1.1
random text
# Header 2
### Header 2.1.1
Execute (Set syntax markdown && Set sw=8):
call SetSyntax('markdown')
set sw=8
Execute (VimwikiTOC):
VimwikiTOC
Expect (With a TOC sw=8):
# Contents
- [Header 1](#Header 1)
- [Header 1.1](#Header 1#Header 1.1)
- [Header 1.1.1](#Header 1#Header 1.1#Header 1.1.1)
- [Header 2](#Header 2)
- [Header 2.1.1](#Header 2#Header 2.1.1)
# Header 1
random text
## Header 1.1
random text
### Header 1.1.1
random text
# Header 2
### Header 2.1.1
Execute (Set sw=4 && VimwikiTOC):
set sw=4
VimwikiTOC
Expect (With a TOC sw=4):
# Contents
- [Header 1](#Header 1)
- [Header 1.1](#Header 1#Header 1.1)
- [Header 1.1.1](#Header 1#Header 1.1#Header 1.1.1)
- [Header 2](#Header 2)
- [Header 2.1.1](#Header 2#Header 2.1.1)
# Header 1
random text
## Header 1.1
random text
### Header 1.1.1
random text
# Header 2
### Header 2.1.1
Do (Destroy some stuff):
jj
dd
jj
dd
Execute (VimwikiTOC):
VimwikiTOC
Expect (Brand new TOC):
# Contents
- [Header 1](#Header 1)
- [Header 1.1](#Header 1#Header 1.1)
- [Header 1.1.1](#Header 1#Header 1.1#Header 1.1.1)
- [Header 2](#Header 2)
- [Header 2.1.1](#Header 2#Header 2.1.1)
# Header 1
random text
## Header 1.1
random text
### Header 1.1.1
random text
# Header 2
### Header 2.1.1
Execute (Let toc_header = Sommaire && VimwikiTOC):
let g:vimwiki_global_vars['toc_header'] = "Sommaire"
VimwikiTOC
Expect (Append a Sommaire && Leave Contents alone):
# Sommaire
- [Header 1](#Header 1)
- [Header 1.1](#Header 1#Header 1.1)
- [Header 1.1.1](#Header 1#Header 1.1#Header 1.1.1)
- [Header 2](#Header 2)
- [Header 2.1.1](#Header 2#Header 2.1.1)
# Header 1
random text
## Header 1.1
random text
### Header 1.1.1
random text
# Header 2
### Header 2.1.1
Do (Destroy some stuff):
jj
dd
jj
dd
Execute (VimwikiTOC):
VimwikiTOC
Expect (Brand new TOC with sommaire):
# Sommaire
- [Header 1](#Header 1)
- [Header 1.1](#Header 1#Header 1.1)
- [Header 1.1.1](#Header 1#Header 1.1#Header 1.1.1)
- [Header 2](#Header 2)
- [Header 2.1.1](#Header 2#Header 2.1.1)
# Header 1
random text
## Header 1.1
random text
### Header 1.1.1
random text
# Header 2
### Header 2.1.1
Include: vader_includes/vader_teardown.vader
# vim: sw=2 ft=conf foldmethod=indent foldlevel=30 foldignore=

View File

@ -0,0 +1,460 @@
Include: vader_setup
# 0 Configure {{{1
##################
Execute (Configure: Set vimwiki list to markdown resource):
Log "Let mapleader = ,"
let mapleader = ','
Log "Declare function DestroyVar"
function! DestroyVar(var)
if ! exists(a:var) | return | endif
execute "unlet " . a:var
endfunction
Log "Declare function AssertTab"
function! AssertTab(nr)
" Vader is creating 2 tabs
AssertEqual a:nr + 2, tabpagenr()
endfunction
Log "Destroy vimrc or previous run heritage"
call DestroyVar('g:vimwiki_list')
call DestroyVar('g:vimwiki_global_vars')
call DestroyVar('g:vimwiki_wikilocal_vars')
Log "Destroy vimrc variable, works better that way"
call DestroyVar('g:vimwiki_default')
call DestroyVar('g:vimwiki_markdown')
call DestroyVar('g:vimwiki_mediawiki')
Log "Declare my vimwiki_list"
let g:vimwiki_list = [{
\ 'path': 'test/resources/testmarkdown',
\ 'syntax': 'markdown',
\ 'ext': '.md'
\ }]
Log "Declare my extension for temporary wiki"
let g:vimwiki_ext2syntax = {'.md': 'markdown'}
Log "Reload vimwiki <- vader_setup.vader"
call ReloadVimwiki()
Execute (Assert: 2 wiki in Index):
AssertEqual 2, len(vimwiki_wikilocal_vars)
Execute (VimwikiIndex):
VimwikiIndex 1
AssertEqual 1, vimwiki#vars#get_bufferlocal('wiki_nr')
AssertEqual 'vimwiki', &filetype
AssertEqual 'test/resources/testmarkdown/', vimwiki_wikilocal_vars[0]['path']
AssertEqual 'test/resources/testmarkdown/index.md', expand('%')
Execute (Open buzz bozz):
edit test/resources/testmarkdown/buzz_bozz.md
AssertEqual 'test/resources/testmarkdown/buzz_bozz.md', expand('%')
# 1 Global {{{1
###############
Execute (===========================================================):
Log "Checking global map"
Do (,ww -> open index [Assert]):
,ww
:AssertEqual 'test/resources/testmarkdown/index.md', expand('%')
\<CR>
:call AssertTab(1)
\<CR>
Do (,wt -> open index in tab [Assert]):
,wt
:AssertEqual 'test/resources/testmarkdown/index.md', expand('%')
\<CR>
:call AssertTab(2)
\<CR>
Do (,w,w -> open diary [Assert]):
,w,w
:AssertEqual 'test/resources/testmarkdown/diary/' . strftime('%Y-%m-%d') . '.md', expand('%')
\<CR>
:call AssertTab(1)
\<CR>
Do (,w,t -> open diary in tab [Assert]):
,w,t
:AssertEqual 'test/resources/testmarkdown/diary/' . strftime('%Y-%m-%d') . '.md', expand('%')
\<CR>
:call AssertTab(2)
\<CR>
Do (,ws -> list and select wiki [Assert]):
,ws
1
\<CR>
:AssertEqual 'test/resources/testmarkdown/index.md', expand('%')
\<CR>
:call AssertTab(1)
\<CR>
Do (,wi -> open diary index [Assert]):
,wi
:AssertEqual 'test/resources/testmarkdown/diary/diary.md', expand('%')
\<CR>
:call AssertTab(1)
\<CR>
Do (,w,y -> open yesterday [Assert]):
,w,y
:AssertEqual 'test/resources/testmarkdown/diary/' . strftime('%Y-%m-%d', localtime() - 60*60*24) . '.md', expand('%')
\<CR>
:call AssertTab(1)
\<CR>
Do (,w,m -> open tomorrow [Assert]):
,wm
:AssertEqual 'test/resources/testmarkdown/diary/' . strftime('%Y-%m-%d', localtime() + 60*60*24) . '.md', expand('%')
\<CR>
:call AssertTab(1)
\<CR>
# 2 Local {{{1
##############
Execute (===========================================================):
Log "Checking local map"
# 2.1 Heading {{{2
##############
Do (,wn -> Create new wiki [Assert]):
,wn
new_file1
\<CR>
:AssertEqual 'test/resources/testmarkdown/new_file1.md', expand('%')
\<CR>
:call AssertTab(1)
\<CR>
Do (,wd -> Delete wiki yes [Assert]):
:edit 'test/resources/testmarkdown/file_new1.md'
\<CR>
,wn
new_file2
\<CR>
ithis is content 2
\<Esc>
,wd
yes
\<CR>
:AssertEqual 'test/resources/testmarkdown/index.md', expand('%')
\<CR>
Do (,wd -> Delete wiki no [Assert]):
:edit 'test/resources/testmarkdown/file_new1.md'
\<CR>
,wn
new_file2
\<CR>
ithis is content 1
\<Esc>
,wd
no
\<CR>
:AssertEqual 'test/resources/testmarkdown/new_file2.md', expand('%')
\<CR>
Do (,wn -> Rename wiki [Assert]):
,wn
new_file1
\<CR>
ithis is content 1
\<Esc>
,wn
new_file2
\<CR>
:AssertEqual 'test/resources/testmarkdown/new_file2.md', expand('%')
\<CR>
Given (Some headings):
# Head 1
## Head 1.1
content 1
# Head2
content 2
Execute (file .md):
file toto.md
edit!
AssertEqual 'vimwiki', &ft
Do (= -> add header level):
=
Expect (Inc header level):
## Head 1
## Head 1.1
content 1
# Head2
content 2
Do (- -> Dec header level):
j
-
Expect (Dec header level):
# Head 1
# Head 1.1
content 1
# Head2
content 2
Do ([[ -> Go to the previous header):
G
k
[[
A placeholder
Expect (placeholder):
# Head 1
## Head 1.1 placeholder
content 1
# Head2
content 2
Do (]] -> Go to the next header):
]]
A placeholder
Expect (placeholder):
# Head 1
## Head 1.1 placeholder
content 1
# Head2
content 2
Do ([= -> Go to the previous header which has the same level):
G
k
[=
A placeholder
Expect (placeholder):
# Head 1 placeholder
## Head 1.1
content 1
# Head2
content 2
Do (]= -> Go to the next header which has the same level):
]=
A placeholder
Expect (placeholder):
# Head 1
## Head 1.1
content 1
# Head2 placeholder
content 2
Do (]u Go one level up):
j
]u
A placeholder
Expect (placeholder):
# Head 1 placeholder
## Head 1.1
content 1
# Head2
content 2
Do ([u Go one level up):
j
[u
A placeholder
Expect (placeholder):
# Head 1 placeholder
## Head 1.1
content 1
# Head2
content 2
# 2.2 List {{{2
##############
Given (Number list):
1. I
1. Relly
2. Love
1. Very
1. Much
3. You
Execute (file .md):
file toto.md
edit!
AssertEqual 'vimwiki', &ft
set sw=2
Do (gll):
gll
Expect (Increase):
1. I
2. Relly
1. Love
1. Very
1. Much
2. You
Do (gLl):
gLl
Expect (Increase self + child):
1. I
1. Relly
1. Love
1. Very
1. Much
2. You
Do (glh):
jjj
glh
Expect (Decrease):
1. I
1. Relly
2. Love
3. Very
1. Much
4. You
Do (gLh):
jjj
gLh
Expect (Decrease self + child):
1. I
1. Relly
2. Love
3. Very
1. Much
4. You
Do (glr):
\<C-A>\<C-A>
glr
Expect (Renumber):
1. I
1. Relly
2. Love
1. Very
1. Much
3. You
Do (gl*):
gl*
Expect (item -> *):
* I
1. Relly
1. Love
1. Very
1. Much
2. You
Do (gL*):
gL*
Expect (list -> *):
* I
1. Relly
* Love
1. Very
1. Much
* You
# 3 Text Object {{{1
####################
Execute (===========================================================):
Log "Checking text object"
# 3.1 HEading Object {{{2
####################
Given (Some headings):
# Head 1
## Head 1.1
content 1
# Head2
content 2
Do (ah):
j
dah
Expect (Change A header including its content up to the next header):
# Head 1
# Head2
content 2
Do (ih):
j
dih
Expect (The content under a header):
# Head 1
## Head 1.1
# Head2
content 2
Do (aH):
daH
Expect (A header including all of its subheaders):
# Head2
content 2
Do (iH):
diH
Expect (Like 'aH', but excluding the header itself):
# Head 1
# Head2
content 2
Include: vader_teardown
# vim: foldmethod=marker foldlevel=30 sw=2

View File

@ -0,0 +1,3 @@
# Buzz Bozz
Cras nisl dolor, mattis condimentum neque ac, cursus tristique est. Sed vel imperdiet ipsum. Curabitur non dictum tortor. Donec massa justo, cursus at suscipit ornare, tempus a tellus. Praesent at orci mi. Praesent sed odio in leo pulvinar vulputate. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Sed eu leo dui. Fusce vitae laoreet massa. Donec ac tempor lectus. Curabitur eget ligula vel purus efficitur congue. Fusce ut pellentesque magna, eget facilisis nunc.

View File

@ -0,0 +1,59 @@
# Test Wiki
This test wiki exists to test various features of VimWiki.
VimWiki Developers: Feel free to *add* to this wiki for additional test features.
Foo bar
foo bar
biz baz
foo\bar
baz{13} <--- this is for testing a literal "baz{13}"
buzzzzz <--- this is for testing regex /buz{5}/
# Links
1. [[buzz_bozz|l_Buzz Bozz]]
2. [l_Buzz_Bozz](buzz_bozz)
3. [l_Flashy](#Typefaces#Flashy)
4. [l_Test Wiki](#Test Wiki)
# Typefaces
## Generic
~~strikeout text~~
`code (no syntax) text`
super^script^
sub,,script,,
## Markdown
**bold text** or __bold text__
*italic text* or _italic text_
***bold_italic text*** or ___italic_bold text___
## Flashy
TODO, DONE, STARTED, FIXME, FIXED, XXX.
# More
## Lorem ipsum dolor ==
Sit amet, consectetur adipiscing elit. Etiam sed efficitur lectus, sit amet consectetur purus. Vestibulum pulvinar, magna et fermentum aliquet, diam libero blandit ex, quis iaculis dui metus sit amet nulla. Mauris auctor massa magna, eu aliquam neque consequat a. Duis lorem nunc, tempus eu dignissim a, euismod sit amet ex. Duis nec condimentum libero. Nulla iaculis fringilla ante, in posuere lorem maximus vel. Nam pulvinar quis diam non ultrices. Vivamus maximus ipsum a placerat rutrum. Nam et consectetur erat, sodales hendrerit ligula.
# Etiam dapibus iaculis
Sed tincidunt vestibulum nunc, in dapibus eros dictum in. Nullam ut dolor nisi.
* blandit nulla mi
* at gravida magna
* maximus eu
### Morbi id sodales sem
Nulla id malesuada velit. Mauris ac nisl orci. Donec maximus ex in sapien fringilla mollis. Praesent eu felis bibendum, auctor justo eget, bibendum purus. Nullam egestas, diam et eleifend tempus, ipsum libero auctor mi, quis rutrum neque metus ac tortor. Vestibulum porttitor tempus vulputate.
## Praesent tempor turpis est
Nunc scelerisque placerat auctor. Donec vel iaculis risus, non commodo nisl. Duis pretium nisi nibh, ac faucibus metus condimentum nec. Aliquam eu euismod lorem. Aenean sit amet tellus sed massa luctus dignissim. Nam tempor sapien quis felis hendrerit fermentum. Nunc vitae vehicula enim.

291
test/syntax.vader Normal file
View File

@ -0,0 +1,291 @@
Include: vader_includes/vader_setup.vader
# 1 Typeface {{{1
#################
Given vimwiki (TODO, XXX):
TODO
DONE
STARTED
FIXME
FIXED
XXX
Execute (Assert Syntax VimwikiTodo):
AssertEqual SyntaxAt(1, 1), 'VimwikiTodo'
AssertEqual SyntaxAt(2, 1), 'VimwikiTodo'
AssertEqual SyntaxAt(3, 1), 'VimwikiTodo'
AssertEqual SyntaxAt(4, 1), 'VimwikiTodo'
AssertEqual SyntaxAt(5, 1), 'VimwikiTodo'
AssertEqual SyntaxAt(6, 1), 'VimwikiTodo'
Given vimwiki (Typeface for markdown like italic):
**bold text 1**
__bold text 2__
*italic text 1*
_italic text 2_
***bold italic text 1***
___bold italic text 2___
~~strikeout text~~
`code (no syntax) text`
sp^script^
sb,,script,,
Execute (Set syntax markdown):
call SetSyntax('markdown')
Execute (Assert Syntax for typeface):
AssertEqual SyntaxAt(1, 4), 'VimwikiBold'
AssertEqual SyntaxAt(2, 4), 'VimwikiBold'
AssertEqual SyntaxAt(3, 4), 'VimwikiItalic'
AssertEqual SyntaxAt(4, 4), 'VimwikiItalic'
AssertEqual SyntaxAt(5, 4), 'VimwikiBoldItalic'
AssertEqual SyntaxAt(6, 4), 'VimwikiItalicBold'
AssertEqual SyntaxAt(7, 4), 'VimwikiDelText'
AssertEqual SyntaxAt(8, 4), 'VimwikiCode'
AssertEqual SyntaxAt(9, 4), 'VimwikiSuperScript'
AssertEqual SyntaxAt(10, 4), 'VimwikiSubScript'
# 2 Links {{{1
#################
Given vimwiki (Wiki Links):
Plain link: >
[[This is a link]]
With description: >
[[This is a link source|Description of the link]]
Interwiki1: >
[[wiki1:This is a link]]
Interwiki2: >
[[wn.My Name:This is a link]]
Interwiki3: >
[[wn.MyWiki:This is a link source|Description of the link]]
Diary: >
[[diary:2012-03-05]]
Anchor1: >
[[Todo List#Tomorrow|Tasks for tomorrow]]
Anchor2: >
[[#Tomorrow]]
Raw1: >
https://github.com/vimwiki/vimwiki.git
Raw2: >
mailto:habamax@gmail.com
Raw3: >
ftp://vim.org
File1: >
[[file:/home/somebody/a/b/c/music.mp3]]
File2: >
[[file:C:/Users/somebody/d/e/f/music.mp3]]
File3: >
[[file:~/a/b/c/music.mp3]]
File4: >
[[file:../assets/data.csv|Important Data]]
File5: >
[[local:C:/Users/somebody/d/e/f/music.mp3]]
File6: >
[[file:/home/user/documents/|Link to a directory]]
Thumbnail links: >
[[http://someaddr.com/bigpicture.jpg|{{http://someaddr.com/thumbnail.jpg}}]]
Execute (Assert Syntax link):
AssertEqual SyntaxAt(2, 6), 'VimwikiLink'
AssertEqual SyntaxAt(4, 6), 'VimwikiLink'
AssertEqual SyntaxAt(6, 6), 'VimwikiLink'
AssertEqual SyntaxAt(8, 6), 'VimwikiLink'
AssertEqual SyntaxAt(10, 6), 'VimwikiLink'
AssertEqual SyntaxAt(12, 6), 'VimwikiLink'
AssertEqual SyntaxAt(14, 6), 'VimwikiLink'
AssertEqual SyntaxAt(16, 6), 'VimwikiLink'
AssertEqual SyntaxAt(18, 6), 'VimwikiLink'
AssertEqual SyntaxAt(20, 6), 'VimwikiLink'
AssertEqual SyntaxAt(22, 6), 'VimwikiLink'
AssertEqual SyntaxAt(24, 6), 'VimwikiLink'
AssertEqual SyntaxAt(26, 6), 'VimwikiLink'
AssertEqual SyntaxAt(28, 6), 'VimwikiLink'
AssertEqual SyntaxAt(30, 6), 'VimwikiLink'
AssertEqual SyntaxAt(32, 6), 'VimwikiLink'
AssertEqual SyntaxAt(34, 6), 'VimwikiLink'
AssertEqual SyntaxAt(36, 6), 'VimwikiLink'
Given vimwiki (Markdown Links):
Inline link: >
[Looks like this](URL)
Image link: >
![Looks like this](URL)
Reference-style links: >
a) [Link Name][Id]
b) [Id][], using the "implicit link name" shortcut
Execute (Set syntax markdown):
call SetSyntax('markdown')
Execute (Assert Syntax link):
AssertEqual SyntaxAt(2, 8), 'VimwikiWeblink1'
AssertEqual SyntaxAt(5, 8), 'VimwikiImage'
AssertEqual SyntaxAt(8, 8), 'VimwikiWikiLink1'
AssertEqual SyntaxAt(9, 8), 'VimwikiWikiLink1'
# 3 Header {{{1
###############
Given vimwiki (Wiki Headers):
= Header level 1 =
== Header level 2 ==
=== Header level 3 ===
==== Header level 4 ====
===== Header level 5 =====
====== Header level 6 ======
Execute (Set syntax default):
call SetSyntax('default')
Execute (Assert Syntax Header):
AssertEqual SyntaxAt(1, 10), 'VimwikiHeader1'
AssertEqual SyntaxAt(2, 10), 'VimwikiHeader2'
AssertEqual SyntaxAt(3, 10), 'VimwikiHeader3'
AssertEqual SyntaxAt(4, 10), 'VimwikiHeader4'
AssertEqual SyntaxAt(5, 10), 'VimwikiHeader5'
AssertEqual SyntaxAt(6, 10), 'VimwikiHeader6'
Given vimwiki (Markdown Headers):
# Header level 1
## Header level 2
### Header level 3
#### Header level 4
##### Header level 5
###### Header level 6
Execute (Set syntax markdown):
call SetSyntax('markdown')
Execute (Assert Syntax Header):
AssertEqual SyntaxAt(1, 10), 'VimwikiHeader1'
AssertEqual SyntaxAt(2, 10), 'VimwikiHeader2'
AssertEqual SyntaxAt(3, 10), 'VimwikiHeader3'
AssertEqual SyntaxAt(4, 10), 'VimwikiHeader4'
AssertEqual SyntaxAt(5, 10), 'VimwikiHeader5'
AssertEqual SyntaxAt(6, 10), 'VimwikiHeader6'
# 10 Code {{{1
# 10.1 Code Indent (4 spaces) {{{2
#################################
Given vimwiki (Code indent):
this is markdown
this is code
Execute (Assert Syntax normal (i.e. no hi)):
AssertEqual SyntaxAt(1, 5), ''
AssertEqual SyntaxAt(2, 5), ''
# 10.2 Code Inline (1 backtick) {{{2
###################################
Given vimwiki (Code inline):
Well use the `man`
Execute (Assert Syntax Code):
AssertEqual SyntaxAt(1, 16), 'VimwikiCode'
# 10.3 Code Block (3 backtiks) {{{2
##################################
Given vimwiki (Markdown, Text and Vim):
this is markdown
this is TODO
```
this is text
```
```vim
" this is vim
set hlsearch
```
Execute (Set syntax markdown):
let g:vimwiki_global_vars['vimwiki_automatic_nested_syntaxes'] = 1
call SetSyntax('markdown')
Execute (Assert ft, normal syntax and VimwikiTodo):
AssertEqual &ft, 'vimwiki'
AssertEqual SyntaxAt(1, 1), ''
AssertEqual SyntaxAt(2, 9), 'VimwikiTodo'
Execute (Assert Code syntax):
AssertEqual SyntaxAt(4, 1), 'VimwikiPreDelim'
AssertEqual SyntaxAt(5, 1), 'VimwikiPre'
AssertEqual SyntaxAt(9, 1), 'vimLineComment'
AssertEqual SyntaxAt(10, 1), 'vimCommand'
# 11 Math {{{1
# 11.1 Math Markdown {{{2
#######################
Given vimwiki (Math markdown):
math inline: $ \sum_i a_i^2 = 1 $
math block:
$$
\sum_i a_i^2
=
1
$$
math block env:
$$%align%
\sum_i a_i^2 &= 1 + 1 \\
&= 2.
$$
Execute (Set syntax markdown):
call SetSyntax('markdown')
Execute (Assert math syntax):
AssertEqual SyntaxAt(1, 18), 'VimwikiEqIn'
let syntax_5 = SyntaxAt(5, 1)
Assert syntax_5 == 'texStatement' || syntax_5 == 'texMathSymbol'
let syntax_12 = SyntaxAt(12, 1)
Assert syntax_12 == 'texStatement' || syntax_5 == 'texMathSymbol'
# 11.2 Math Wiki {{{2
##############################
Given vimwiki (Math wiki):
math inline: $ \sum_i a_i^2 = 1 $
math block:
{{$
\sum_i a_i^2
=
1
}}$
math block env:
{{$%align%
\sum_i a_i^2 &= 1 + 1 \\
&= 2.
}}$
Execute (Set syntax markdown):
call SetSyntax('default')
Execute (Assert math syntax):
AssertEqual SyntaxAt(1, 18), 'VimwikiEqIn'
let syntax_5 = SyntaxAt(5, 1)
Assert syntax_5 == 'texStatement' || syntax_5 == 'texMathSymbol'
let syntax_12 = SyntaxAt(12, 1)
Assert syntax_12 == 'texStatement' || syntax_5 == 'texMathSymbol'
Include: vader_includes/vader_teardown.vader
# vim: foldmethod=marker foldlevel=30 sw=2

157
test/table_autoformat.vader Normal file
View File

@ -0,0 +1,157 @@
Include: vader_includes/vader_setup.vader
# Autoformat {{{1
#################
Given vimwiki (Unaligned table):
| title1 | title2 |
| - | - |
| a1 | b1 |
| a2 | |
Execute (Rename file wiki_test.md for table expand):
file wiki_test.md
Do (A to trigger insertLeave):
A
Expect (Table autoformat):
| title1 | title2 |
| - | - |
| a1 | b1 |
| a2 | |
Do (gqq to reformats table after making changes.):
gqq
Expect (Table autoformat):
| title1 | title2 |
| - | - |
| a1 | b1 |
| a2 | |
Execute (Option table_reduce_last_col = 1):
let g:vimwiki_global_vars['table_reduce_last_col'] = 1
Do (A to trigger insertLeave):
A
Expect (Last column not expanded):
| title1 | title2 |
| - | - |
| a1 | b1 |
| a2 | |
Execute (Option table_reduce_last_col = 0 [restore]):
let g:vimwiki_global_vars['table_reduce_last_col'] = 0
Execute (Option table_auto_fmt = 0):
let g:vimwiki_global_vars['table_auto_fmt'] = 0
Expect (Same as input):
| title1 | title2 |
| - | - |
| a1 | b1 |
| a2 | |
Execute (Option table_auto_fmt = 1 [restore]):
let g:vimwiki_global_vars['table_auto_fmt'] = 1
# Move and edit cells {{{1
##########################
Do (Use <Tab> in insert mode):
GI
\<Tab>
this_is_16_chars
\<Tab>
this_is_16_chars
\<Esc>
Expect (Table autoformated with more content):
| title1 | title2 |
| - | - |
| a1 | b1 |
| this_is_16_charsa2 | this_is_16_chars |
Do (VimwikiTableMoveColumnRight):
gg:VimwikiTableMoveColumnRight\<CR>
Expect (Column inverted):
| title2 | title1 |
| - | - |
| b1 | a1 |
| | a2 |
Do (CR must insert new row):
GI\<Cr>a3
Expect (Table with new row starting by a3):
| title1 | title2 |
| - | - |
| a1 | b1 |
| a2 | |
| a3 | |
# VimwikiTable Command {{{1
###########################
Given (Nothing):
Execute (VimwikiTable):
VimwikiTable
Expect (Table 5 x 2):
| | | | | |
|---|---|---|---|---|
| | | | | |
Execute (VimwikiTable 8 3):
VimwikiTable 8 3
Expect (Table 8 x 3):
| | | | | | | | |
|---|---|---|---|---|---|---|---|
| | | | | | | | |
| | | | | | | | |
# Justify Cell Content {{{1
###########################
Given vimwiki (To be justified from help file [Coffe price]):
| Date | Item | Price |
|------------|:------:|--------:|
| yest |Coffee |$15.00 |
| 2017-02-13 |Tea |$2.10 |
| 2017-03-14 |Cake |$143.12 |
Execute (Rename file wiki_test.md for table expand):
file wiki_test.md
Do (A to trigger insertLeave):
A
Expect (Text justified):
| Date | Item | Price |
|------------|:------:|--------:|
| yest | Coffee | $15.00 |
| 2017-02-13 | Tea | $2.10 |
| 2017-03-14 | Cake | $143.12 |
Include: vader_includes/vader_teardown.vader
# vim: foldmethod=marker foldlevel=30

View File

@ -46,3 +46,29 @@ Before (Define functions):
unlet g:loaded_vimwiki unlet g:loaded_vimwiki
source plugin/vimwiki.vim source plugin/vimwiki.vim
endfunction endfunction
" Copy wiki test resources so that vimtest user can write them
function! CopyResources()
call system('cp -r /testplugin/test/resources/* $HOME/')
" Make diary directory
call system('mkdir $HOME/testwiki/diary')
call system('mkdir $HOME/testmarkdown/diary')
endfunction
" Delete Hidden buffer, usefull to clean
" Stole from: https://stackoverflow.com/a/8459043/2544873
function! DeleteHiddenBuffers()
let tpbl=[]
call map(range(1, tabpagenr('$')), 'extend(tpbl, tabpagebuflist(v:val))')
for buf in filter(range(1, bufnr('$')), 'bufexists(v:val) && index(tpbl, v:val)==-1')
silent execute 'bwipeout!' buf
endfor
endfunction
" Write current file: helper to hide `set bt=`
function! WriteMe()
set bt=
write %
endfunction
# vim: ft=vim

View File

@ -6,26 +6,32 @@ set nocompatible
filetype plugin indent on filetype plugin indent on
syntax enable syntax enable
" Wiki's resources to be used after:
" :!cp -r /testplugin/test/resources/* $HOME/
" or from a test.vader file Execute block:
" call CopyResources()
" This complication aims for these copies to be writable
" default syntax " default syntax
let vimwiki_default = {} let vimwiki_default = {}
let vimwiki_default.path = 'test/resources/vimwiki/default' let vimwiki_default.path = $HOME . '/testwiki'
let vimwiki_default.path_html = 'test/resources/default/html' let vimwiki_default.path_html = $HOME . '/html/default'
let vimwiki_default.syntax = 'default' let vimwiki_default.syntax = 'default'
let vimwiki_default.ext = '.wiki' let vimwiki_default.ext = '.wiki'
let vimwiki_default.name = 'DefaultSyntax' let vimwiki_default.name = 'DefaultSyntax'
" markdown syntax - https://github.github.com/gfm/ " markdown syntax - https://github.github.com/gfm/
let vimwiki_markdown = {} let vimwiki_markdown = {}
let vimwiki_markdown.path = 'test/resources/vimwiki/markdown' let vimwiki_markdown.path = $HOME . '/testmarkdown'
let vimwiki_markdown.path_html = '~/vimwiki/markdown/html' let vimwiki_markdown.path_html = $HOME . '/html/markdown'
let vimwiki_markdown.syntax = 'markdown' let vimwiki_markdown.syntax = 'markdown'
let vimwiki_markdown.ext = '.md' let vimwiki_markdown.ext = '.md'
let vimwiki_markdown.name = 'MarkdownSyntax' let vimwiki_markdown.name = 'MarkdownSyntax'
" mediawiki syntax - https://www.mediawiki.org/wiki/Help:Formatting " mediawiki syntax - https://www.mediawiki.org/wiki/Help:Formatting
let vimwiki_mediawiki = {} let vimwiki_mediawiki = {}
let vimwiki_mediawiki.path = 'test/resources/vimwiki/mediawiki' let vimwiki_mediawiki.path = $HOME . '/testmediawiki'
let vimwiki_mediawiki.path_html = 'test/resources/vimwiki/mediawiki/html' let vimwiki_mediawiki.path_html = $HOME . '/html/mediawiki'
let vimwiki_mediawiki.syntax = 'mediawiki' let vimwiki_mediawiki.syntax = 'mediawiki'
let vimwiki_mediawiki.ext = '.mw' let vimwiki_mediawiki.ext = '.mw'
let vimwiki_mediawiki.name = 'MediaWikiSyntax' let vimwiki_mediawiki.name = 'MediaWikiSyntax'