Skip to content

Commit 2ae290a

Browse files
komar007artempyanykh
authored andcommitted
test: Add tests against GLFM header ID disambiguation (#383)
1 parent f10dff6 commit 2ae290a

File tree

2 files changed

+79
-0
lines changed

2 files changed

+79
-0
lines changed

Tests/AstTests.fs

+54
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,60 @@ And this?
8888
"H2 {h22}"
8989
]
9090

91+
[<Fact>]
92+
let testSymsWhenRepeatedHeadingsGlfm () =
93+
let doc =
94+
"""
95+
# X^
96+
# A
97+
# A
98+
# X
99+
# Z
100+
## A
101+
"""
102+
103+
let strukt =
104+
Parser.parse { ParserSettings.Default with titleFromHeading = false } (Text.mkText doc)
105+
106+
Helpers.checkInlineSnapshot _.ToString() strukt.Symbols [
107+
"Doc"
108+
"H1 {a}"
109+
"H1 {a-1}"
110+
"H1 {x}"
111+
"H1 {x-1}"
112+
"H1 {z}"
113+
"H2 {a-2}"
114+
]
115+
116+
[<Fact>]
117+
let testSymsWhenRepeatedHeadingsNoGlfm () =
118+
let doc =
119+
"""
120+
# X^
121+
# A
122+
# A
123+
# X
124+
# Z
125+
## A
126+
"""
127+
128+
let strukt =
129+
Parser.parse
130+
{
131+
ParserSettings.Default with
132+
titleFromHeading = false
133+
glfmHeadingIds = false
134+
}
135+
(Text.mkText doc)
136+
137+
Helpers.checkInlineSnapshot _.ToString() strukt.Symbols [
138+
"Doc"
139+
"H1 {a}"
140+
"H1 {x}"
141+
"H1 {z}"
142+
"H2 {a}"
143+
]
144+
91145
[<Fact>]
92146
let testSymsWhenTitleFromHeadingIsOn () =
93147
let doc =

Tests/ConfigTests.fs

+25
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,20 @@ candidates = 100
115115

116116
Assert.Equal(Some expected, actual)
117117

118+
[<Fact>]
119+
let testParse_8 () =
120+
let content =
121+
"""
122+
[core]
123+
markdown.glfm_heading_ids.enable = true
124+
"""
125+
126+
let actual = Config.tryParse content
127+
128+
let expected = { Config.Empty with coreMarkdownGlfmHeadingIdsEnable = Some true }
129+
130+
Assert.Equal(Some expected, actual)
131+
118132
[<Fact>]
119133
let testParse_broken_0 () =
120134
let content =
@@ -180,6 +194,17 @@ candidates = -1
180194
let actual = Config.tryParse content
181195
Assert.Equal(None, actual)
182196

197+
[<Fact>]
198+
let testParse_broken_6 () =
199+
let content =
200+
"""
201+
[core]
202+
markdown.glfm_heading_ids.enable = -1
203+
"""
204+
205+
let actual = Config.tryParse content
206+
Assert.Equal(None, actual)
207+
183208
[<Fact>]
184209
let testDefault () =
185210
let content =

0 commit comments

Comments
 (0)