Skip to content

Commit

Permalink
Tests
Browse files Browse the repository at this point in the history
  • Loading branch information
freak4pc committed Aug 9, 2024
1 parent f7ec387 commit 1cf1d4f
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 5 deletions.
8 changes: 3 additions & 5 deletions Sources/MarkdownUI/Renderer/TextInlineRenderer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,10 @@ private struct TextInlineRenderer {

private mutating func renderSoftBreak() {
switch self.softBreakMode {
case .space where self.shouldSkipNextWhitespace:
self.shouldSkipNextWhitespace = false
case .space:
if self.shouldSkipNextWhitespace {
self.shouldSkipNextWhitespace = false
} else {
self.defaultRender(.softBreak)
}
self.defaultRender(.softBreak)
case .lineBreak:
self.shouldSkipNextWhitespace = true
self.defaultRender(.lineBreak)
Expand Down
42 changes: 42 additions & 0 deletions Tests/MarkdownUITests/MarkdownTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -300,5 +300,47 @@

assertSnapshot(of: view, as: .image(layout: layout))
}

func testSoftBreakModeSpace() {
let view = Markdown {
#"""
# This is a heading
Item 1
Item 2
Item 3
Item 4
I would **very much** like to write
A long paragraph that spans _multiple lines_
But should ~~render differently~~ based on
soft break mode
"""#
}
.markdownSoftBreakMode(.space)

assertSnapshot(of: view, as: .image(layout: layout))
}

func testSoftBreakModeLineBreak() {
let view = Markdown {
#"""
# This is a heading
Item 1
Item 2
Item 3
Item 4
I would **very much** like to write
A long paragraph that spans _multiple lines_
But should ~~render differently~~ based on
soft break mode
"""#
}
.markdownSoftBreakMode(.lineBreak)

assertSnapshot(of: view, as: .image(layout: layout))
}
}
#endif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 1cf1d4f

Please sign in to comment.