Skip to content

Commit 95953ce

Browse files
committed
fix: tests corrected and attribute is now optional
1 parent 9028f92 commit 95953ce

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

Sources/WebUI/Core/Document.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ public struct Script {
3030

3131
/// Optional attribute controlling how the script is loaded and executed.
3232
let attribute: ScriptAttribute?
33+
34+
init(src: String, attribute: ScriptAttribute? = nil) {
35+
self.src = src
36+
self.attribute = attribute
37+
}
3338
}
3439

3540
/// Represents an immutable HTML document with metadata, scripts, stylesheets, and content.

Tests/WebUITests/Core/DocumentTests.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ import Testing
154154
scripts: [
155155
Script(src: "https://cdn.example.com/script1.js", attribute: .async),
156156
Script(src: "/public/script2.js", attribute: .defer),
157+
Script(src: "/public/script3.js"),
157158
]
158159
) {
159160
"Script Test"
@@ -165,6 +166,7 @@ import Testing
165166
)
166167
)
167168
#expect(rendered.contains("<script defer src=\"/public/script2.js\"></script>"))
169+
#expect(rendered.contains("<script src=\"/public/script3.js\"></script>"))
168170
}
169171

170172
/// Tests that custom stylesheets are correctly added to the document head.

0 commit comments

Comments
 (0)