@testable import PureXML import Testing @Suite("HTML5 document tree construction") struct HTMLDocumentTests { private func document(_ html: String) -> String { PureXML.HTML.serialize(PureXML.HTML.parseDocument(html)) } @Test("Implied html, head, and body wrap a bare fragment") func test_impliedStructure() { #expect(document("
hello
") == "hello
") } @Test("Head-only elements are routed into the head") func test_headRouting() { let html = "body
" let expected = "body
" #expect(document(html) == expected) } @Test("Explicit html, head, and body are honored") func test_explicitStructure() { let html = "one
two
" #expect(document(html) == "one
two
") } @Test("html attributes are preserved on the implied structure") func test_htmlAttributes() { #expect(document("x
") == "x
") } // MARK: Table tree construction /// Wraps a body fragment in the implied document structure for comparison. private func bodyDocument(_ inner: String) -> String { "\(inner)" } @Test("A bare table row gets an implied tbody") func test_impliedTbody() { #expect(document("| x |
| x |
| x |
| x |
| h |
|---|
| h |
|---|
| a |
| b |
| a |
| b |