Swift Testing for Unit Tests PART 1 (#5119)

* migrated a lot of unit tests to Swift Testing and added a new implementation for deferred fulfillment

more tests migration

Cleaned the code manually to establish some good patterns

more code improvements

some more code improvements

removed empty tests

update project

* more pr suggestions and cleanups

* removed the TestSetup pattern

* fixing claude not reusing tests

* pr suggestion + added indent rule to swiftformat so that we can prevent AIs to change that
This commit is contained in:
Mauro
2026-02-19 16:20:47 +01:00
committed by GitHub
parent fc03e05697
commit 7982aef855
118 changed files with 4630 additions and 4129 deletions
@@ -215,7 +215,7 @@ class AttributedStringBuilderTests: XCTestCase {
checkLinkIn(attributedString: attributedStringBuilder.fromHTML(string), expectedLink: expectedLink.absoluteString, expectedRuns: 3)
checkLinkIn(attributedString: attributedStringBuilder.fromPlain(string), expectedLink: expectedLink.absoluteString, expectedRuns: 3)
}
func testDefaultFont() {
let htmlString = "<b>Test</b> <i>string</i> "
@@ -313,7 +313,7 @@ class AttributedStringBuilderTests: XCTestCase {
XCTFail("Couldn't find blockquote")
}
// swiftlint:enable line_length
func testBlockquoteWithLink() {
@@ -515,7 +515,7 @@ class AttributedStringBuilderTests: XCTestCase {
checkAttachment(attributedString: attributedStringFromHTML, expectedRuns: 1)
let attributedStringFromPlain = attributedStringBuilder.fromPlain(string)
checkAttachment(attributedString: attributedStringFromPlain, expectedRuns: 1)
let string2 = "Hello @room"
let attributedStringFromHTML2 = attributedStringBuilder.fromHTML(string2)
checkAttachment(attributedString: attributedStringFromHTML2, expectedRuns: 2)
@@ -824,7 +824,7 @@ class AttributedStringBuilderTests: XCTestCase {
XCTFail("Could not build the attributed string")
return
}
guard let link = attributedString.runs.first(where: { $0.link != nil })?.link else {
XCTFail("Couldn't find the link")
return
@@ -840,7 +840,7 @@ class AttributedStringBuilderTests: XCTestCase {
XCTFail("Could not build the attributed string")
return
}
guard let link = attributedString.runs.first(where: { $0.link != nil })?.link else {
XCTFail("Couldn't find the link")
return
@@ -1108,7 +1108,7 @@ class AttributedStringBuilderTests: XCTestCase {
XCTAssertEqual(link.confirmationParameters?.internalURL.absoluteString, "https://matrix.org")
XCTAssertEqual(link.confirmationParameters?.displayString, "👉️ #room:matrix.org")
}
func testMxExternalPaymentDetailsRemoved() {
var htmlString = "This is visible.<span data-msc4286-external-payment-details> But this is hidden <a href=\"https://matrix.org\">and this link too</a></span>"
@@ -1138,7 +1138,7 @@ class AttributedStringBuilderTests: XCTestCase {
return
}
}
// MARK: - Private
private func checkLinkIn(attributedString: AttributedString?, expectedLink: String, expectedRuns: Int) {