Skip to content

Commit 7d5fb86

Browse files
added more unit tests
1 parent 4ce3617 commit 7d5fb86

File tree

1 file changed

+24
-7
lines changed

1 file changed

+24
-7
lines changed

Tests/HTMLKitTests/HTMLKitTests.swift

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ extension HTMLKitTests {
3737
}
3838
@Test func element_button() {
3939
#expect(#button(type: .submit) == "<button type=\"submit\"></button>")
40+
#expect(#button(formenctype: .applicationXWWWFormURLEncoded, formmethod: .get, formtarget: ._blank, popovertargetaction: .hide) == "<button formenctype=\"application/x-www-form-urlencoded\" formmethod=\"get\" formtarget=\"_blank\" popovertargetaction=\"hide\"></button>")
41+
#expect(#button(formenctype: .multipartFormData, formmethod: .post, popovertargetaction: .show) == "<button formenctype=\"multipart/form-data\" formmethod=\"post\" popovertargetaction=\"show\"></button>")
42+
#expect(#button(formenctype: .textPlain, formmethod: .get, type: .reset) == "<button formenctype=\"text/plain\" formmethod=\"get\" type=\"reset\"></button>")
4043
}
4144
@Test func element_canvas() {
4245
#expect(#canvas(height: .percent(4), width: .em(2.69)) == "<canvas height=\"4%\" width=\"2.69em\"></canvas>")
@@ -55,7 +58,7 @@ extension HTMLKitTests {
5558
@Test func element_img() {
5659
#expect(#img(sizes: ["(max-height: 500px) 1000px", "(min-height: 25rem)"], srcset: ["https://paradigm-app.com", "https://litleagues.com"]) == "<img sizes=\"(max-height: 500px) 1000px,(min-height: 25rem)\" srcset=\"https://paradigm-app.com,https://litleagues.com\">")
5760
}
58-
@Test func test_link() {
61+
@Test func element_link() {
5962
#expect(#link(as: .document, imagesizes: ["lmno", "p"]) == "<link as=\"document\" imagesizes=\"lmno,p\">")
6063
}
6164
@Test func element_ol() {
@@ -72,11 +75,26 @@ extension HTMLKitTests {
7275
#expect(#script(type: .module) == "<script type=\"module\"></script>")
7376
#expect(#script(type: .speculationrules) == "<script type=\"speculationrules\"></script>")
7477
}
75-
@Test func element_text_area() {
76-
#expect(#textarea(autocomplete: ["email", "password"], rows: 5) == "<textarea autocomplete=\"email password\" rows=\"5\"></textarea>")
78+
@Test func element_style() {
79+
#expect(#style(blocking: .render) == "<style blocking=\"render\"></style>")
80+
}
81+
@Test func element_template() {
82+
#expect(#template(shadowrootclonable: .false, shadowrootdelegatesfocus: false, shadowrootmode: .closed, shadowrootserializable: true) == "<template shadowrootclonable=\"false\" shadowrootmode=\"closed\" shadowrootserializable></template>")
83+
}
84+
@Test func element_textarea() {
85+
#expect(#textarea(autocomplete: ["email", "password"], dirname: .ltr, rows: 5, wrap: .soft) == "<textarea autocomplete=\"email password\" dirname=\"ltr\" rows=\"5\" wrap=\"soft\"></textarea>")
86+
}
87+
@Test func element_th() {
88+
#expect(#th(rowspan: 2, scope: .colgroup) == "<th rowspan=\"2\" scope=\"colgroup\"></th>")
89+
}
90+
@Test func element_track() {
91+
#expect(#track(default: true, kind: .captions, label: "tesT") == "<track default kind=\"captions\" label=\"tesT\">")
7792
}
7893
@Test func element_video() {
7994
#expect(#video(controlslist: [.nodownload, .nofullscreen, .noremoteplayback]) == "<video controlslist=\"nodownload nofullscreen noremoteplayback\"></video>")
95+
#expect(#video(crossorigin: .anonymous) == "<video crossorigin=\"anonymous\"></video>")
96+
#expect(#video(crossorigin: .useCredentials) == "<video crossorigin=\"use-credentials\"></video>")
97+
#expect(#video(preload: .metadata) == "<video preload=\"metadata\"></video>")
8098
}
8199

82100
@Test func element_custom() {
@@ -169,12 +187,11 @@ extension HTMLKitTests {
169187
string = #div(attributes: [.title(HTMLKitTests.patrick)])
170188
#expect(string == "<div title=\"Patrick Star\"></div>")
171189

172-
/*let mr_crabs:StaticString = "Mr. Crabs"
173-
let static_string:StaticString = #div(attributes: [.title(mr_crabs)])
174-
#expect(static_string == "<div title=\"Mr. Crabs\"></div>")*/
190+
let static_string:StaticString = #div(attributes: [.title("Mr. Crabs")])
191+
#expect(static_string == "<div title=\"Mr. Crabs\"></div>")
175192
}
176193
@Test func third_party_func() {
177-
//#expect(#div(attributes: [.title(HTMLKitTests.spongebobCharacter("patrick"))]) == "<div title=\"Patrick Star\"></div>")
194+
#expect(#div(attributes: [.title(HTMLKitTests.spongebobCharacter("patrick"))]) == "<div title=\"Patrick Star\"></div>")
178195
}
179196
}
180197

0 commit comments

Comments
 (0)