Skip to content

Commit

Permalink
Update test case for more human-readable
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyle-Ye committed Jun 26, 2023
1 parent 3306b9b commit 16b212e
Showing 1 changed file with 30 additions and 13 deletions.
43 changes: 30 additions & 13 deletions Tests/SwiftDocCTests/Rendering/RenderContentCompilerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -137,31 +137,48 @@ class RenderContentCompilerTests: XCTestCase {
var compiler = RenderContentCompiler(context: context, bundle: bundle, identifier: ResolvedTopicReference(bundleIdentifier: bundle.identifier, path: "/path", fragment: nil, sourceLanguage: .swift))

let source = #"""
This text should\
appear on two lines.
Backslash before new line\
is an explicit hard line break.
This text should
appear on two lines.
Two spaces before new line
is a hard line break.
This is the second paragraph.
Paragraph can't end with hard line break.\
# Headings can't end with hard line break.\
Code blocks ignore\
hard line breaks.
A single space before new line
is a soft line break.
"""#
let document = Document(parsing: source)
let expectedDump = """
let expectedDump = #"""
Document
├─ Paragraph
│ ├─ Text "This text should"
│ ├─ Text "Backslash before new line"
│ ├─ LineBreak
│ └─ Text "appear on two lines."
│ └─ Text "is an explicit hard line break."
├─ Paragraph
│ ├─ Text "This text should"
│ ├─ Text "Two spaces before new line"
│ ├─ LineBreak
│ └─ Text "appear on two lines."
│ └─ Text "is a hard line break."
├─ Paragraph
│ └─ Text "Paragraph can’t end with hard line break.\"
├─ Heading level: 1
│ └─ Text "Headings can’t end with hard line break.\"
├─ CodeBlock language: none
│ Code blocks ignore\
│ hard line breaks.
└─ Paragraph
└─ Text "This is the second paragraph."
"""
├─ Text "A single space before new line"
├─ SoftBreak
└─ Text "is a soft line break."
"""#
XCTAssertEqual(document.debugDescription(), expectedDump)
let result = document.children.flatMap { compiler.visit($0) }
XCTAssertEqual(result.count, 3)
XCTAssertEqual(result.count, 6)
do {
guard case let .paragraph(paragraph) = result[0] as? RenderBlockContent else {
XCTFail("RenderCotent result is not the expected RenderBlockContent.paragraph(Paragraph)")
Expand Down

0 comments on commit 16b212e

Please sign in to comment.