@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 = "T

body

" let expected = "T

body

" #expect(document(html) == expected) } @Test("Explicit html, head, and body are honored") func test_explicitStructure() { let html = "T

Hi

" #expect(document(html) == "T

Hi

") } @Test("Flow content before any head element starts the body") func test_flowStartsBody() { #expect(document("
x
") == "
x
") } @Test("A head element after body content stays in the body's flow") func test_explicitBodyThenContent() { 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

") } }