diff options
Diffstat (limited to 'Tests/NorgUITests/RenderingSmokeTests.swift')
| -rw-r--r-- | Tests/NorgUITests/RenderingSmokeTests.swift | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/Tests/NorgUITests/RenderingSmokeTests.swift b/Tests/NorgUITests/RenderingSmokeTests.swift new file mode 100644 index 0000000..39c9eb5 --- /dev/null +++ b/Tests/NorgUITests/RenderingSmokeTests.swift @@ -0,0 +1,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") + } +} |