Skip to content

Commit d22fe0d

Browse files
committed
Fix TOC test
1 parent c133ce1 commit d22fe0d

File tree

3 files changed

+53
-44
lines changed

3 files changed

+53
-44
lines changed

test/folding-toc.vader

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -121,28 +121,28 @@ Execute (check TOC):
121121
let res = getloclist(0)
122122
let elem = res[0]
123123
AssertEqual elem.lnum, 1
124-
AssertEqual elem.text, 'chap 1'
124+
AssertEqual elem.text, '# chap 1'
125125
let elem = res[1]
126126
AssertEqual elem.lnum, 15
127-
AssertEqual elem.text, ' chap 1.1'
127+
AssertEqual elem.text, '## chap 1.1'
128128
let elem = res[2]
129129
AssertEqual elem.lnum, 25
130-
AssertEqual elem.text, ' chap 1.1.1'
130+
AssertEqual elem.text, '### chap 1.1.1'
131131
let elem = res[3]
132132
AssertEqual elem.lnum, 30
133-
AssertEqual elem.text, 'chap 2'
133+
AssertEqual elem.text, '# chap 2'
134134
let elem = res[4]
135135
AssertEqual elem.lnum, 34
136-
AssertEqual elem.text, ' chap 2.1'
136+
AssertEqual elem.text, '## chap 2.1'
137137
let elem = res[5]
138138
AssertEqual elem.lnum, 41
139-
AssertEqual elem.text, 'chap 3'
139+
AssertEqual elem.text, '# chap 3'
140140
let elem = res[6]
141141
AssertEqual elem.lnum, 45
142-
AssertEqual elem.text, 'chap 4'
142+
AssertEqual elem.text, '# chap 4'
143143
let elem = res[7]
144144
AssertEqual elem.lnum, 50
145-
AssertEqual elem.text, ' chap 4.1'
145+
AssertEqual elem.text, '## chap 4.1'
146146

147147
Given markdown;
148148
---
@@ -175,5 +175,5 @@ Execute (check Toc of yaml front matter):
175175
AssertEqual len(res), 1
176176
let elem = res[0]
177177
AssertEqual elem.lnum, 8
178-
AssertEqual elem.text, ' heading'
178+
AssertEqual elem.text, '## heading'
179179
unlet g:vim_markdown_frontmatter

test/toc-autofit.vader

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ Execute (toc window autofit width):
4545
:Toc
4646
let real_width = winwidth(0)
4747
:lclose
48-
let expected_width = len(line) + 2*5 + 1 + 3 - 7
48+
let expected_width = len(line) + 1 + 3
4949
AssertEqual real_width, expected_width
5050
set nonumber
51-
" 2 spaces * 5 additional header levels + 1 space for first header +
52-
" 3 spaces for line numbers - 7 chars ('###### ') that don't show up on the TOC
51+
" 1 space for first header + 3 spaces for line numbers
52+
" 7 chars ('###### ') are removed, but added to `:Toc` again.
5353

test/toc.vader

Lines changed: 41 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,14 @@ test
2828

2929
Execute (Toc setex headers):
3030
:Toc
31+
:setl modifiable
32+
:%s/\m^\([^|]*|\)\{2} //
33+
:setl nomodifiable nomodified
3134

3235
Expect (setex headers):
33-
header 1
34-
header 2
35-
header 3
36+
# header 1
37+
## header 2
38+
### header 3
3639

3740
Given markdown;
3841
# header 1
@@ -49,11 +52,14 @@ test
4952

5053
Execute (Toc atx headers):
5154
:Toc
55+
:setl modifiable
56+
:%s/\m^\([^|]*|\)\{2} //
57+
:setl nomodifiable nomodified
5258

5359
Expect (atx headers):
54-
header 1
55-
header 2
56-
header 3
60+
# header 1
61+
## header 2
62+
### header 3
5763

5864
Given markdown;
5965
ATX tests.
@@ -135,34 +141,37 @@ setex h2
135141

136142
Execute (Toc multiple headers):
137143
:Toc
144+
:setl modifiable
145+
:%s/\m^\([^|]*|\)\{2} //
146+
:setl nomodifiable nomodified
138147

139148
Expect (multiple headers):
140-
h1 space
141-
h1 nospace
142-
h1 2 spaces
143-
h1 trailing hash
144-
h2 space
145-
h2 nospace
146-
h2 trailing hash
147-
h3 space
148-
h3 nospace
149-
h3 trailing hash
150-
h4
151-
h5
152-
h6
153-
h1 before h2
154-
h2 between h1s
155-
h1 after h2
156-
setex h1
157-
setex h2
158-
setex h1 single punctuation
159-
setex h1 punctuation longer than header
160-
setex h1 before atx
161-
atx h2
162-
atx h3
163-
atx h1
164-
setex h2
165-
atx h3 2
149+
# h1 space
150+
# h1 nospace
151+
# h1 2 spaces
152+
# h1 trailing hash
153+
## h2 space
154+
## h2 nospace
155+
## h2 trailing hash
156+
### h3 space
157+
### h3 nospace
158+
### h3 trailing hash
159+
#### h4
160+
##### h5
161+
###### h6
162+
# h1 before h2
163+
## h2 between h1s
164+
# h1 after h2
165+
# setex h1
166+
## setex h2
167+
# setex h1 single punctuation
168+
# setex h1 punctuation longer than header
169+
# setex h1 before atx
170+
## atx h2
171+
### atx h3
172+
# atx h1
173+
## setex h2
174+
### atx h3 2
166175

167176
Execute:
168177
:lclose

0 commit comments

Comments
 (0)