mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 21:33:26 +00:00
Add support for <details> and <summary> tags (#6077)
This commit is contained in:
@@ -242,6 +242,31 @@ struct AttributedStringBuilderTests {
|
||||
#expect(foundLink)
|
||||
}
|
||||
|
||||
@Test
|
||||
func detailsAndSummary() throws {
|
||||
let htmlString = "Before<details><summary>Expand me</summary><p>Hidden content</p></details>After"
|
||||
|
||||
let attributedString = try #require(attributedStringBuilder.fromHTML(htmlString), "Could not build the attributed string")
|
||||
|
||||
#expect(String(attributedString.characters) == "BeforeHidden content\nAfter")
|
||||
|
||||
let components = attributedString.formattedComponents
|
||||
|
||||
#expect(components.count == 3)
|
||||
#expect(components.map(\.type) == [.plainText, .details(summary: "Expand me"), .plainText])
|
||||
#expect(components[1].attributedString.string == "Hidden content")
|
||||
}
|
||||
|
||||
@Test
|
||||
func detailsWithoutSummary() throws {
|
||||
let htmlString = "<details><p>Content</p></details>"
|
||||
|
||||
let attributedString = try #require(attributedStringBuilder.fromHTML(htmlString), "Could not build the attributed string")
|
||||
|
||||
#expect(String(attributedString.characters) == "Content")
|
||||
#expect(attributedString.formattedComponents.map(\.type) == [.details(summary: L10n.a11yViewDetails)])
|
||||
}
|
||||
|
||||
@Test
|
||||
func singleBlockquote() throws {
|
||||
let htmlString = "<blockquote>Blockquote</blockquote><p>Another paragraph</p>"
|
||||
|
||||
Reference in New Issue
Block a user