mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 21:33:26 +00:00
Replies now display mentions with @displayname (#1957)
* reply with mentions * fixed a bug and wrote a test for it * error message
This commit is contained in:
@@ -555,6 +555,52 @@ class AttributedStringBuilderTests: XCTestCase {
|
||||
XCTAssertEqual(foundLink, url)
|
||||
XCTAssertEqual(foundAttachments, 2)
|
||||
}
|
||||
|
||||
func testMultipleMentions2() {
|
||||
guard let url = URL(string: "https://matrix.to/#/@test:matrix.org") else {
|
||||
XCTFail("Invalid url")
|
||||
return
|
||||
}
|
||||
|
||||
let string = "\(url) @room"
|
||||
guard let attributedStringFromHTML = attributedStringBuilder.fromHTML(string) else {
|
||||
XCTFail("Attributed string is nil")
|
||||
return
|
||||
}
|
||||
|
||||
var foundAttachments = 0
|
||||
var foundLink: URL?
|
||||
for run in attributedStringFromHTML.runs {
|
||||
if run.attachment != nil {
|
||||
foundAttachments += 1
|
||||
}
|
||||
|
||||
if let link = run.link {
|
||||
foundLink = link
|
||||
}
|
||||
}
|
||||
XCTAssertEqual(foundLink, url)
|
||||
XCTAssertEqual(foundAttachments, 2)
|
||||
|
||||
guard let attributedStringFromPlain = attributedStringBuilder.fromPlain(string) else {
|
||||
XCTFail("Attributed string is nil")
|
||||
return
|
||||
}
|
||||
|
||||
foundAttachments = 0
|
||||
foundLink = nil
|
||||
for run in attributedStringFromPlain.runs {
|
||||
if run.attachment != nil {
|
||||
foundAttachments += 1
|
||||
}
|
||||
|
||||
if let link = run.link {
|
||||
foundLink = link
|
||||
}
|
||||
}
|
||||
XCTAssertEqual(foundLink, url)
|
||||
XCTAssertEqual(foundAttachments, 2)
|
||||
}
|
||||
|
||||
// MARK: - Private
|
||||
|
||||
|
||||
Reference in New Issue
Block a user