@@ -9,51 +9,6 @@ import Testing
99import HTMLKit
1010
1111struct ElementTests {
12- // MARK: Escape
13- @Test func escape_html( ) {
14- let unescaped : String = " <!DOCTYPE html><html>Test</html> "
15- let escaped : String = " <!DOCTYPE html><html>Test</html> "
16- var expected_result : String = " <p> \( escaped) </p> "
17-
18- var string : String = #html( p ( " <!DOCTYPE html><html>Test</html> " ) )
19- #expect( string == expected_result)
20-
21- string = #escapeHTML( " <!DOCTYPE html><html>Test</html> " )
22- #expect( string == escaped)
23-
24- string = #escapeHTML( html ( " Test " ) )
25- #expect( string == escaped)
26-
27- string = #html( p ( #escapeHTML( html ( " Test " ) ) ) )
28- #expect( string == expected_result)
29-
30- string = #html( p ( " \( unescaped. escapingHTML ( escapeAttributes: false ) ) " ) )
31- #expect( string == expected_result)
32-
33- expected_result = " <div title= \" <p> \" ><p></p></div> "
34- string = #html( div ( attributes: [ . title( " <p> " ) ] , StaticString ( " <p></p> " ) ) )
35- #expect( string == expected_result)
36-
37- string = #html( div ( attributes: [ . title( " <p> " ) ] , " <p></p> " ) )
38- #expect( string == expected_result)
39-
40- string = #html( p ( " What's 9 + 10? \" 21 \" ! " ) )
41- #expect( string == " <p>What's 9 + 10? "21"!</p> " )
42-
43- string = #html( option ( value: " bad boy <html> " ) )
44- expected_result = " <option value= \" bad boy <html> \" ></option> "
45- #expect( string == expected_result)
46- }
47- }
48-
49-
50-
51- // MARK: Elements
52-
53-
54-
55-
56- extension ElementTests {
5712 // MARK: html
5813 @Test func _html( ) {
5914 var string : StaticString = #html( html ( ) )
@@ -63,12 +18,21 @@ extension ElementTests {
6318 #expect( string == " <!DOCTYPE html><html xmlns= \" test \" ></html> " )
6419 }
6520
66- // MARK: HTMLKit.element
21+ // MARK: HTMLKit.< element>
6722 @Test func with_library_decl( ) {
6823 let string : StaticString = #html( html ( HTMLKit . body ( ) ) )
6924 #expect( string == " <!DOCTYPE html><html><body></body></html> " )
7025 }
26+ }
27+
28+
29+
30+ // MARK: Elements
7131
32+
33+
34+
35+ extension ElementTests {
7236 // MARK: a
7337 // https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a
7438 @Test func _a( ) {
@@ -412,7 +376,7 @@ extension ElementTests {
412376 }
413377
414378 // MARK: custom
415- @Test func _custom ( ) {
379+ @Test func custom_element ( ) {
416380 var bro : StaticString = #html( custom ( tag: " bro " , isVoid: false ) )
417381 #expect( bro == " <bro></bro> " )
418382
@@ -475,27 +439,29 @@ extension ElementTests {
475439 }*/
476440
477441 /*@Test func not_allowed() {
478- let _:StaticString = #div(attributes: [.id("1"), .id("2"), .id("3"), .id("4")])
479- let _:StaticString = #a(
480- attributes: [
481- .class(["lets go"])
482- ],
483- attributionSrc: ["lets go"],
484- ping: ["lets go"]
442+ let _:StaticString = #html(div(attributes: [.id("1"), .id("2"), .id("3"), .id("4")]))
443+ let _:StaticString = #html(
444+ a(
445+ attributes: [
446+ .class(["lets go"])
447+ ],
448+ attributionsrc: ["lets go"],
449+ ping: ["lets go"]
450+ )
485451 )
486- let _:StaticString = #input(
487- accept: ["lets,go"],
488- autocomplete: ["lets go"]
452+ let _:StaticString = #html(
453+ input(
454+ accept: ["lets,go"],
455+ autocomplete: ["lets go"]
456+ )
489457 )
490- let _:StaticString = #link(
491- imagesizes: ["lets,go"],
492- imagesrcset: ["lets,go"],
493- rel: ["lets go"],
494- sizes: ["lets,go"]
458+ let _:StaticString = #html(
459+ link(
460+ imagesizes: ["lets,go"],
461+ imagesrcset: ["lets,go"],
462+ rel: .stylesheet,
463+ size: "lets,go"
464+ )
495465 )
496- let _:String = #div(attributes: [.custom("potof gold1", "\(1)"), .custom("potof gold2", "2")])
497-
498- let _:StaticString = #div(attributes: [.trailingSlash])
499- let _:StaticString = #html(custom(tag: "slash", isVoid: false, attributes: [.trailingSlash]))
500466 }*/
501467}
0 commit comments