File tree Expand file tree Collapse file tree 14 files changed +253
-0
lines changed
Expand file tree Collapse file tree 14 files changed +253
-0
lines changed Original file line number Diff line number Diff line change 1+ MYVIM ?= nvim --clean --headless
2+ export QUIT = 1
3+
4+ tests := $(wildcard test* .vim)
5+
6+ .PHONY : cleanup $(tests )
7+
8+ test : $(tests )
9+
10+ $(tests ) :
11+ @rm -rf wiki-tmp
12+ @cp -r wiki wiki-tmp
13+ @$(MYVIM ) -u $@
14+ @rm -rf wiki-tmp
Original file line number Diff line number Diff line change 1+ source ../init.vim
2+ runtime plugin /wiki.vim
3+
4+ let g: wiki_log_verbose = 0
5+
6+ silent edit wiki- tmp/index .wiki
7+
8+ " Refile something not within a section should return with error message
9+ normal 2 G
10+ silent call wiki#page#refile (#{target_page: ' targetA' })
11+ let s: log = wiki#log#get ()
12+ call assert_equal (1 , len (s: log ))
13+ call assert_equal (' error' , s: log [0 ].type )
14+ call assert_equal (' No source section recognized!' , s: log [0 ].msg[0 ])
15+
16+ " Refile to nonexisting target should return with error message
17+ normal ! 13 G
18+ silent call wiki#page#refile (#{target_page: ' targetDoesNotExist' })
19+ let s: log = wiki#log#get ()
20+ call assert_equal (2 , len (s: log ))
21+ call assert_equal (' error' , s: log [1 ].type )
22+ call assert_equal (' Target page was not found!' , s: log [1 ].msg[0 ])
23+
24+ call wiki#test#finished ()
Original file line number Diff line number Diff line change 1+ source ../init.vim
2+ runtime plugin /wiki.vim
3+
4+ " Refile Section 1 of index to targetA
5+ silent edit wiki- tmp/sourceSameFile.wiki
6+ normal ! 10 G
7+ silent call wiki#page#refile (#{target_lnum: 20 })
8+
9+ " Check that content was properly removed from index and moved to targetA
10+ call assert_equal (
11+ \ readfile (' wiki-tmp/sourceSameFile.ref' ),
12+ \ readfile (' wiki-tmp/sourceSameFile.wiki' ))
13+
14+ " Check that all links to the previous location are updated
15+ call assert_equal (
16+ \ ' [[sourceSameFile#Tasks#Bar#Subheading]]' ,
17+ \ readfile (' wiki-tmp/links.wiki' )[10 ])
18+
19+ call wiki#test#finished ()
Original file line number Diff line number Diff line change 1+ source ../init.vim
2+ runtime plugin /wiki.vim
3+
4+ " Refile Section 1 of index to targetA
5+ silent edit wiki- tmp/index .wiki
6+ normal ! 15 G
7+ silent call wiki#page#refile (#{target_page: ' targetA' , target_lnum: 10 })
8+
9+ " Check that content was properly removed from index and moved to targetA
10+ call assert_equal (
11+ \ readfile (' wiki-tmp/index.ref2' ),
12+ \ readfile (' wiki-tmp/index.wiki' ))
13+ call assert_equal (
14+ \ readfile (' wiki-tmp/targetA.ref2' ),
15+ \ readfile (' wiki-tmp/targetA.wiki' ))
16+
17+ " Check that all links to the previous location are updated
18+ call assert_equal (
19+ \ ' [[targetA#Section 2#Foo bar Baz]]' ,
20+ \ readfile (' wiki-tmp/index.wiki' )[7 ])
21+ call assert_equal (
22+ \ ' [[targetA#Section 2#Foo bar Baz]]' ,
23+ \ readfile (' wiki-tmp/links.wiki' )[8 ])
24+
25+ call wiki#test#finished ()
Original file line number Diff line number Diff line change 1+ source ../init.vim
2+ runtime plugin /wiki.vim
3+
4+ silent edit wiki- tmp/index .wiki
5+ normal ! 13 G
6+ silent call wiki#page#refile (#{target_page: ' targetA' })
7+
8+ " Check that content was properly moved from index to targetA
9+ call assert_equal (
10+ \ readfile (' wiki-tmp/index.ref' ),
11+ \ readfile (' wiki-tmp/index.wiki' ))
12+ call assert_equal (
13+ \ readfile (' wiki-tmp/targetA.ref' ),
14+ \ readfile (' wiki-tmp/targetA.wiki' ))
15+
16+ " Check that all links to the previous location are updated
17+ call assert_equal (
18+ \ ' [[targetA#Section 1]]' ,
19+ \ readfile (' wiki-tmp/index.wiki' )[6 ])
20+ call assert_equal (
21+ \ ' [[targetA#Section 1#Foo bar Baz]]' ,
22+ \ readfile (' wiki-tmp/index.wiki' )[7 ])
23+ call assert_equal (
24+ \ ' [[targetA#Section 1]]' ,
25+ \ readfile (' wiki-tmp/links.wiki' )[7 ])
26+ call assert_equal (
27+ \ ' [[targetA#Section 1#Foo bar Baz]]' ,
28+ \ readfile (' wiki-tmp/links.wiki' )[8 ])
29+
30+ call wiki#test#finished ()
Original file line number Diff line number Diff line change 1+ Intro text here.
2+
3+ # Intro
4+
5+ This is a wiki.
6+
7+ [[targetA#Section 1]]
8+ [[targetA#Section 1#Foo bar Baz]]
9+
10+ This-is-a-wiki.
11+
Original file line number Diff line number Diff line change 1+ Intro text here.
2+
3+ # Intro
4+
5+ This is a wiki.
6+
7+ [[#Section 1]]
8+ [[targetA#Section 2#Foo bar Baz]]
9+
10+ This-is-a-wiki.
11+
12+ # Section 1
13+
Original file line number Diff line number Diff line change 1+ Intro text here.
2+
3+ # Intro
4+
5+ This is a wiki.
6+
7+ [[#Section 1 ]]
8+ [[#Section 1#Foo bar Baz ]]
9+
10+ This-is-a-wiki.
11+
12+ # Section 1
13+
14+ ## Foo bar Baz
15+
Original file line number Diff line number Diff line change 1+ # Intro
2+
3+ This is a wiki.
4+
5+ [[BadName ]]
6+ [[subdir/BadName ]]
7+
8+ [[index#Section 1 ]]
9+ [[index#Section 1#Foo bar Baz ]]
10+
11+ [[sourceSameFile#Inbox#Bar#Subheading ]]
Original file line number Diff line number Diff line change 1+ # Inbox
2+ Link to: [[#Tasks#Bar]]
3+ ## Foo
4+
5+ Random text here.
6+
7+ # Tasks
8+
9+ ## Baz
10+
11+ Even more random text here.
12+
13+ ## Bar
14+
15+ More random text here.
16+
17+ ### Subheading
18+
19+ More here.
20+
21+ # Someday
22+
23+ ## Qux
24+
25+ More text.
26+
You can’t perform that action at this time.
0 commit comments