Fix for line breaks (#2224)

This commit is contained in:
Mauro
2023-12-11 16:43:31 +01:00
committed by GitHub
parent 4cba5687c6
commit a248bdbd95
5 changed files with 55 additions and 5 deletions
+23
View File
@@ -88,4 +88,27 @@ class StringTests: XCTestCase {
func testEllipsizeNotNeeded() {
XCTAssertEqual("ellipsize".ellipsize(length: 15), "ellipsize")
}
func testReplaceBreakOccurrences() {
let input0 = "</p><p>"
let input1 = "</p>\n<p>"
let input2 = "</p>\n\n<p>"
let input3 = "</p>\n\n\n\n<p>"
let input4 = "<p>a</p>\n<p>b</p>"
let input5 = "empty"
let expectedOutput0 = input0
let expectedOutput1 = "<br><br>"
let expectedOutput2 = "<br><br><br>"
let expectedOutput3 = "<br><br><br><br><br>"
let expectedOutput4 = "<p>a<br><br>b</p>"
let expectedOutput5 = input5
XCTAssertEqual(input0.replacingHtmlBreaksOccurrences(), expectedOutput0)
XCTAssertEqual(input1.replacingHtmlBreaksOccurrences(), expectedOutput1)
XCTAssertEqual(input2.replacingHtmlBreaksOccurrences(), expectedOutput2)
XCTAssertEqual(input3.replacingHtmlBreaksOccurrences(), expectedOutput3)
XCTAssertEqual(input4.replacingHtmlBreaksOccurrences(), expectedOutput4)
XCTAssertEqual(input5.replacingHtmlBreaksOccurrences(), expectedOutput5)
}
}
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:8388baf6d6dff565d85ce4e75053f465a923e3e3216649e860f8103fe2bf2293
size 212392
oid sha256:afb864a0a68877a81dc46f01add0830bb6de243de11c70181624bd48b3886916
size 212427