Skip to content

Commit b963ce8

Browse files
chore: add ability to test plugin with lines rather than requiring files, remove most of the file based tests
1 parent 84d413b commit b963ce8

25 files changed

+899
-930
lines changed

doc/render-markdown.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*render-markdown.txt* For 0.10.0 Last change: 2025 March 25
1+
*render-markdown.txt* For 0.10.0 Last change: 2025 March 26
22

33
==============================================================================
44
Table of Contents *render-markdown-table-of-contents*

tests/ad_hoc_spec.lua

Lines changed: 99 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -2,99 +2,123 @@
22

33
local util = require('tests.util')
44

5-
describe('ad_hoc.md', function()
6-
it('custom', function()
7-
util.setup('tests/data/ad_hoc.md')
8-
9-
local marks, row = util.marks(), util.row()
10-
11-
marks
12-
:add(row:get(), nil, 0, nil, util.heading.sign(1))
13-
:add(row:get(), row:get(), 0, 1, util.heading.icon(1))
14-
:add(row:get(), row:inc(), 0, 0, util.heading.bg(1))
15-
16-
marks
17-
:add(row:inc(), nil, 0, nil, util.heading.sign(2))
18-
:add(row:get(), row:get(), 0, 0, {
5+
describe('ad hoc', function()
6+
it('setext', function()
7+
util.setup.text({
8+
'Heading 2 Line 1',
9+
'Heading 2 Line 2',
10+
'---',
11+
})
12+
local marks = util.marks()
13+
:add(0, nil, 0, nil, util.heading.sign(2))
14+
:add(0, 0, 0, 0, {
1915
virt_text = { { '󰲣 ', 'RmH2:RmH2Bg' } },
2016
virt_text_pos = 'inline',
2117
})
22-
:add(row:get(), row:inc(), 0, 0, util.heading.bg(2))
23-
:add(row:get(), row:get(), 0, 0, {
18+
:add(0, 1, 0, 0, util.heading.bg(2))
19+
:add(1, 1, 0, 0, {
2420
virt_text = { { ' ', 'RmH2:RmH2Bg' } },
2521
virt_text_pos = 'inline',
2622
})
27-
:add(row:get(), row:inc(), 0, 0, util.heading.bg(2))
28-
:add(row:get(), row:get(), 0, 0, {
23+
:add(1, 2, 0, 0, util.heading.bg(2))
24+
:add(2, 2, 0, 0, {
2925
virt_text = { { ' ', 'RmH2:RmH2Bg' } },
3026
virt_text_pos = 'inline',
3127
})
32-
:add(row:get(), row:get(), 0, 3, util.conceal())
33-
:add(row:get(), row:inc(), 0, 0, util.heading.bg(2))
28+
:add(2, 2, 0, 3, util.conceal())
29+
:add(2, 3, 0, 0, util.heading.bg(2))
30+
util.assert_view(marks, {
31+
'󰫎 󰲣 Heading 2 Line 1',
32+
' Heading 2 Line 2',
33+
'',
34+
})
35+
end)
3436

35-
marks:add(row:inc(), row:get(), 0, 2, util.bullet(1))
37+
it('shortcut', function()
38+
util.setup.text({ '- [Normal Shortcut]' })
39+
local marks = util.marks()
40+
marks:add(0, 0, 0, 2, util.bullet(1))
41+
util.assert_view(marks, { '● Normal Shortcut' })
42+
end)
3643

37-
marks
38-
:add(row:inc(), row:get(), 0, 2, util.bullet(1))
39-
:add(row:get(), row:get(), 2, 3, util.conceal())
40-
:add(row:get(), row:get(), 3, 14, util.link('wiki'))
41-
:add(row:get(), row:get(), 14, 15, util.conceal())
44+
it('wikilink', function()
45+
util.setup.text({ '- [[Basic One]] Then normal text' })
46+
local marks = util.marks()
47+
:add(0, 0, 0, 2, util.bullet(1))
48+
:add(0, 0, 2, 3, util.conceal())
49+
:add(0, 0, 3, 14, util.link('wiki'))
50+
:add(0, 0, 14, 15, util.conceal())
51+
util.assert_view(marks, { '● 󱗖 Basic One Then normal text' })
52+
end)
4253

43-
marks
44-
:add(row:inc(), row:get(), 0, 2, util.bullet(1))
45-
:add(row:get(), row:get(), 2, 3, util.conceal())
46-
:add(row:get(), row:get(), 3, 24, util.link('wiki'))
47-
:add(row:get(), row:get(), 4, 13, util.conceal())
48-
:add(row:get(), row:get(), 24, 25, util.conceal())
54+
it('wikilink with alias', function()
55+
util.setup.text({ '- [[Nickname|With Alias]] Something important' })
56+
local marks = util.marks()
57+
:add(0, 0, 0, 2, util.bullet(1))
58+
:add(0, 0, 2, 3, util.conceal())
59+
:add(0, 0, 3, 24, util.link('wiki'))
60+
:add(0, 0, 4, 13, util.conceal())
61+
:add(0, 0, 24, 25, util.conceal())
62+
util.assert_view(marks, { '● 󱗖 With Alias Something important' })
63+
end)
4964

50-
marks
51-
:add(row:inc(), row:get(), 0, 2, util.bullet(1))
52-
:add(row:get(), row:get(), 2, 3, util.conceal())
53-
:add(row:get(), row:get(), 2, 20, util.link('email'))
54-
:add(row:get(), row:get(), 2, 20, util.highlight('link'))
55-
:add(row:get(), row:get(), 19, 20, util.conceal())
65+
it('email', function()
66+
util.setup.text({ '- <[email protected]> Email' })
67+
local marks = util.marks()
68+
:add(0, 0, 0, 2, util.bullet(1))
69+
:add(0, 0, 2, 3, util.conceal())
70+
:add(0, 0, 2, 20, util.link('email'))
71+
:add(0, 0, 2, 20, util.highlight('link'))
72+
:add(0, 0, 19, 20, util.conceal())
73+
util.assert_view(marks, { '● 󰀓 [email protected] Email' })
74+
end)
5675

57-
marks
58-
:add(row:inc(), row:get(), 0, 2, util.bullet(1))
59-
:add(row:get(), row:get(), 2, 3, util.conceal())
60-
:add(row:get(), row:get(), 2, 26, util.link('git'))
61-
:add(row:get(), row:get(), 2, 26, util.highlight('link'))
62-
:add(row:get(), row:get(), 25, 26, util.conceal())
76+
it('bare url', function()
77+
util.setup.text({ '- <http://www.github.com/> Bare URL' })
78+
local marks = util.marks()
79+
:add(0, 0, 0, 2, util.bullet(1))
80+
:add(0, 0, 2, 3, util.conceal())
81+
:add(0, 0, 2, 26, util.link('git'))
82+
:add(0, 0, 2, 26, util.highlight('link'))
83+
:add(0, 0, 25, 26, util.conceal())
84+
util.assert_view(marks, { '● 󰊤 http://www.github.com/ Bare URL' })
85+
end)
6386

64-
marks:add(row:inc(), row:get(), 0, 2, util.bullet(1))
65-
marks:add(row:get(), row:get(), 2, 61, util.link('youtube'))
87+
it('youtube', function()
88+
util.setup.text({ '- [Youtube Link](https://www.youtube.com/watch?v=dQw4w9WgXcQ)' })
89+
local marks = util.marks()
90+
marks:add(0, 0, 0, 2, util.bullet(1))
91+
marks:add(0, 0, 2, 61, util.link('youtube'))
92+
util.assert_view(marks, { '● 󰗃 Youtube Link' })
93+
end)
6694

67-
marks:add(row:inc(), row:get(), 0, 2, util.bullet(1))
68-
marks:add(row:get(), row:get(), 16, 25, {
69-
virt_text = { { '¹ ᴵⁿᶠᵒ', 'RmLink' } },
70-
virt_text_pos = 'inline',
71-
conceal = '',
72-
})
73-
marks:add(row:inc(2), row:get(), 0, 16, util.conceal())
74-
marks:add(row:inc(2), row:get(), 0, 9, {
75-
virt_text = { { '¹ ᴵⁿᶠᵒ', 'RmLink' } },
76-
virt_text_pos = 'inline',
77-
conceal = '',
95+
it('footnote', function()
96+
util.setup.text({
97+
'- Footnote Link [^1 Info]',
98+
'[^1 Info]: Some Info',
7899
})
79-
100+
local marks = util.marks()
101+
:add(0, 0, 0, 2, util.bullet(1))
102+
:add(0, 0, 16, 25, {
103+
virt_text = { { '¹ ᴵⁿᶠᵒ', 'RmLink' } },
104+
virt_text_pos = 'inline',
105+
conceal = '',
106+
})
107+
:add(1, 1, 0, 9, {
108+
virt_text = { { '¹ ᴵⁿᶠᵒ', 'RmLink' } },
109+
virt_text_pos = 'inline',
110+
conceal = '',
111+
})
80112
util.assert_view(marks, {
81-
'󰫎 1 󰲡 Heading',
82-
' 2',
83-
'󰫎 3 󰲣 Heading 2 Line 1',
84-
' 4 Heading 2 Line 2',
85-
' 5',
86-
' 6',
87-
' 7 ● Normal Shortcut',
88-
' 8 ● 󱗖 Basic One Then normal text',
89-
' 9 ● 󱗖 With Alias Something important',
90-
' 10 ● 󰀓 [email protected] Email',
91-
' 11 ● 󰊤 http://www.github.com/ Bare URL',
92-
' 12 ● 󰗃 Youtube Link',
93-
' 13 ● Footnote Link ¹ ᴵⁿᶠᵒ',
94-
' 14',
95-
' 15',
96-
' 16',
97-
' 17 ¹ ᴵⁿᶠᵒ: Some Info',
113+
'● Footnote Link ¹ ᴵⁿᶠᵒ',
114+
'¹ ᴵⁿᶠᵒ: Some Info',
98115
})
99116
end)
117+
118+
it('html comment', function()
119+
util.setup.text({ '<!-- comment -->' })
120+
local marks = util.marks()
121+
marks:add(0, 0, 0, 16, util.conceal())
122+
util.assert_view(marks, { '' })
123+
end)
100124
end)

tests/box_dash_quote_spec.lua

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ local util = require('tests.util')
44

55
describe('box_dash_quote.md', function()
66
it('default', function()
7-
util.setup('demo/box_dash_quote.md')
7+
util.setup.file('demo/box_dash_quote.md')
88

99
local marks, row = util.marks(), util.row()
1010

@@ -49,17 +49,17 @@ describe('box_dash_quote.md', function()
4949
:add(row:inc(), row:get(), 0, 4, util.quote(' %s ', 'RmQuote'))
5050

5151
util.assert_view(marks, {
52-
'󰫎 1 󰲡 Checkbox / Dash / Quote',
53-
' 2',
54-
' 3 󰄱 Unchecked Checkbox',
55-
' 4 󰱒 Checked Checkbox',
56-
' 5 󰥔 Todo Checkbox',
57-
' 6 ● Regular List Item',
58-
' 7',
59-
' 8 ──────────────────────────────────────────────────────────────────────────',
60-
' 9',
61-
' 10 ▋ Quote line 1',
62-
' 11 ▋ Quote line 2',
52+
'󰫎 󰲡 Checkbox / Dash / Quote',
53+
'',
54+
' 󰄱 Unchecked Checkbox',
55+
' 󰱒 Checked Checkbox',
56+
' 󰥔 Todo Checkbox',
57+
' ● Regular List Item',
58+
'',
59+
' ──────────────────────────────────────────────────────────────────────────────',
60+
'',
61+
' ▋ Quote line 1',
62+
' ▋ Quote line 2',
6363
})
6464
end)
6565
end)

tests/callout_spec.lua

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ local util = require('tests.util')
44

55
describe('callout.md', function()
66
it('default', function()
7-
util.setup('demo/callout.md')
7+
util.setup.file('demo/callout.md')
88

99
local marks, row = util.marks(), util.row()
1010

@@ -104,41 +104,41 @@ describe('callout.md', function()
104104
:add(row:inc(), row:get(), 0, 2, util.quote('%s ', err))
105105

106106
util.assert_view(marks, {
107-
'󰫎 1 󰲡 Note',
108-
' 2',
109-
' 3 ▋ 󰋽 Note',
110-
' 4 ',
111-
' 5 ▋ A regular note',
112-
' 6 ',
113-
' 7 ▋ With a second paragraph',
114-
' 8',
115-
'󰫎 9 󰲡 Tip',
116-
' 10',
117-
' 11 ▋ 󰌶 Tip',
118-
' 12 ',
119-
'󰢱 13 ▋ 󰢱 lua',
120-
" 14 ▋ print('Standard tip')",
121-
' 15 ▋ ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀',
122-
' 16',
123-
'󰫎 17 󰲡 Important',
124-
' 18',
125-
' 19 ▋ 󰅾 Important',
126-
' 20 ▋ Exceptional info',
127-
' 21',
128-
'󰫎 22 󰲡 Warning',
129-
' 23',
130-
' 24 ▋ 󰀪 Custom Title',
131-
' 25 ▋ Dastardly surprise',
132-
' 26',
133-
'󰫎 27 󰲡 Caution',
134-
' 28',
135-
' 29 ▋ 󰳦 Caution',
136-
' 30 ▋ Cautionary tale',
137-
' 31',
138-
'󰫎 32 󰲡 Bug',
139-
' 33',
140-
' 34 ▋ 󰨰 Bug',
141-
' 35 ▋ Custom bug',
107+
'󰫎 󰲡 Note',
108+
'',
109+
' ▋ 󰋽 Note',
110+
'',
111+
' ▋ A regular note',
112+
'',
113+
' ▋ With a second paragraph',
114+
'',
115+
'󰫎 󰲡 Tip',
116+
'',
117+
' ▋ 󰌶 Tip',
118+
'',
119+
'󰢱 ▋ 󰢱 lua',
120+
" ▋ print('Standard tip')",
121+
' ▋ ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀',
122+
'',
123+
'󰫎 󰲡 Important',
124+
'',
125+
' ▋ 󰅾 Important',
126+
' ▋ Exceptional info',
127+
'',
128+
'󰫎 󰲡 Warning',
129+
'',
130+
' ▋ 󰀪 Custom Title',
131+
' ▋ Dastardly surprise',
132+
'',
133+
'󰫎 󰲡 Caution',
134+
'',
135+
' ▋ 󰳦 Caution',
136+
' ▋ Cautionary tale',
137+
'',
138+
'󰫎 󰲡 Bug',
139+
'',
140+
' ▋ 󰨰 Bug',
141+
' ▋ Custom bug',
142142
})
143143
end)
144144
end)

0 commit comments

Comments
 (0)