blob: 39c9eb57317822f8757dc0fd5aff744768c2ed16 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
import NorgKit
import Testing
@testable import NorgUI
@Suite struct RenderingSmokeTests {
@Test func rangeableBlockExposesBodyForRecursion() {
let doc = NorgParser.parse("$ Norg\nA structured note format.")
guard case .definition(_, _, let body, _) = doc.blocks.first else {
Issue.record("Expected a definition")
return
}
#expect(!body.isEmpty)
}
@Test func headingNestsContentAsTreeChildren() {
let nodes = NorgParser.parse("* Title\nbody text below").tree()
guard let heading = nodes.first, case .heading = heading.block else {
Issue.record("Expected a heading root")
return
}
#expect(!heading.children.isEmpty)
}
@Test func nestedListNestsAsTreeChildren() {
let nodes = NorgParser.parse("- one\n-- nested").tree()
guard let item = nodes.first else {
Issue.record("Expected a list item")
return
}
#expect(item.children.count == 1)
}
@Test func nonCodeRangedTagIsRouted() {
let doc = NorgParser.parse("@math\nx^2 + y^2 = z^2\n@end")
guard case .rangedTag(let name, _, _, _) = doc.blocks.first else {
Issue.record("Expected a ranged tag")
return
}
#expect(name == ["math"])
}
@Test func codeFenceBecomesCodeBlock() {
let doc = NorgParser.parse("@code swift\nlet x = 1\n@end")
guard case .codeBlock(let language, _, _) = doc.blocks.first else {
Issue.record("Expected a code block")
return
}
#expect(language == "swift")
}
}
|