import Testing @testable import PureXML @Suite("HTML5 select content model") struct HTMLSelectTests { private func body(_ html: String) -> String { let full = PureXML.HTML.serialize(PureXML.HTML.parseDocument(html)) let wrapper = "" guard full.hasPrefix(wrapper), full.hasSuffix("") else { return full } return String(full.dropFirst(wrapper.count).dropLast("".count)) } @Test("Options nest and close one another") func test_options() { #expect(body("") == "") } @Test("optgroup closes an open option") func test_optgroup() { #expect(body("") == "") } @Test("A nested select closes the open one") func test_nestedSelect() { #expect(body("") == "") } @Test("An input closes the select and is placed after it") func test_inputClosesSelect() { #expect(body("") == "") } @Test("A table cell closes a select that is inside a table") func test_selectInTable() { let expected = "
xy
" #expect(body("
xy
") == expected) } }