Skip to content

Commit ca33769

Browse files
committed
I would like to think the end is in sight for these tests, but I suspect not.
1 parent 03219c8 commit ca33769

File tree

6 files changed

+126
-0
lines changed

6 files changed

+126
-0
lines changed

Tests/IgniteTesting/Elements/Audio.swift

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,26 @@ class AudioTests: IgniteTestSuite {
3838
</audio>
3939
""")
4040
}
41+
42+
@Test("Unrecognized file extension produces no source tag")
43+
func unrecognizedExtension() async throws {
44+
let element = Audio("/audio/mystery.xyz")
45+
let output = element.markupString()
46+
47+
#expect(output == """
48+
<audio controls>\
49+
Your browser does not support the audio element.\
50+
</audio>
51+
""")
52+
}
53+
54+
@Test("Mixed recognized and unrecognized files only renders recognized sources")
55+
func mixedExtensions() async throws {
56+
let element = Audio("/audio/song.mp3", "/audio/song.xyz", "/audio/song.ogg")
57+
let output = element.markupString()
58+
59+
#expect(output.contains(#"<source src="/audio/song.mp3" type="audio/mpeg">"#))
60+
#expect(output.contains(#"<source src="/audio/song.ogg" type="audio/ogg">"#))
61+
#expect(!output.contains("song.xyz"))
62+
}
4163
}

Tests/IgniteTesting/Elements/Emphasis.swift

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,28 @@ class EmphasisTests: IgniteTestSuite {
2121

2222
#expect(output == "<em>Although Markdown is still easier, to be honest! </em>")
2323
}
24+
25+
@Test("Emphasis with builder initializer wrapping inline element")
26+
func builderWithInlineElement() async throws {
27+
let element = Emphasis {
28+
Strong("very important")
29+
}
30+
let output = element.markupString()
31+
32+
#expect(output == "<em><strong>very important</strong></em>")
33+
}
34+
35+
@Test("Emphasis with multiple children via builder")
36+
func builderWithMultipleChildren() async throws {
37+
let element = Emphasis {
38+
"Hello "
39+
Strong("world")
40+
}
41+
let output = element.markupString()
42+
43+
#expect(output.contains("Hello "))
44+
#expect(output.contains("<strong>world</strong>"))
45+
#expect(output.hasPrefix("<em>"))
46+
#expect(output.hasSuffix("</em>"))
47+
}
2448
}

Tests/IgniteTesting/Elements/Quote.swift

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,33 @@ class QuoteTests: IgniteTestSuite {
4646
</blockquote>
4747
""")
4848
}
49+
50+
@Test("Quote with multiple children renders all content")
51+
func multipleChildren() async throws {
52+
let element = Quote {
53+
Text("First line")
54+
Text("Second line")
55+
}
56+
57+
let output = element.markupString()
58+
59+
#expect(output.contains("<p>First line</p>"))
60+
#expect(output.contains("<p>Second line</p>"))
61+
#expect(output.hasPrefix("<blockquote"))
62+
#expect(output.hasSuffix("</blockquote>"))
63+
}
64+
65+
@Test("Quote caption with inline element renders styled caption")
66+
func captionWithInlineElement() async throws {
67+
let element = Quote {
68+
Text("To be or not to be")
69+
} caption: {
70+
Emphasis("Shakespeare")
71+
}
72+
73+
let output = element.markupString()
74+
75+
#expect(output.contains("<footer class=\"blockquote-footer\">"))
76+
#expect(output.contains("<em>Shakespeare</em>"))
77+
}
4978
}

Tests/IgniteTesting/Elements/Section.swift

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,32 @@ class SectionTests: IgniteTestSuite {
4343
</section>
4444
""")
4545
}
46+
47+
@Test("Default header prominence renders as h2")
48+
func defaultHeaderProminence() async throws {
49+
let element = Section("Default Heading") {
50+
Span("Content")
51+
}
52+
53+
let output = element.markupString()
54+
55+
#expect(output == """
56+
<section>\
57+
<h2>Default Heading</h2>\
58+
<span>Content</span>\
59+
</section>
60+
""")
61+
}
62+
63+
@Test("Section with ID includes id on containing element")
64+
func sectionWithID() async throws {
65+
let element = Section {
66+
Span("Content")
67+
}
68+
.id("my-section")
69+
70+
let output = element.markupString()
71+
72+
#expect(output == "<div id=\"my-section\"><span>Content</span></div>")
73+
}
4674
}

Tests/IgniteTesting/Elements/Strong.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,5 @@ import Testing
2828

2929
#expect(output == "<strong>\(strongText)</strong>")
3030
}
31+
3132
}

Tests/IgniteTesting/Elements/Video.swift

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,26 @@ import Testing
3939
</video>
4040
""")
4141
}
42+
43+
@Test("Unrecognized file extension produces no source tag")
44+
func unrecognizedExtension() async throws {
45+
let element = Video("/videos/mystery.xyz")
46+
let output = element.markupString()
47+
48+
#expect(output == """
49+
<video controls>\
50+
Your browser does not support the video tag.\
51+
</video>
52+
""")
53+
}
54+
55+
@Test("Mixed recognized and unrecognized files only renders recognized sources")
56+
func mixedExtensions() async throws {
57+
let element = Video("/videos/clip.mp4", "/videos/clip.xyz", "/videos/clip.webm")
58+
let output = element.markupString()
59+
60+
#expect(output.contains(#"<source src="/videos/clip.mp4" type="video/mp4" />"#))
61+
#expect(output.contains(#"<source src="/videos/clip.webm" type="video/webm" />"#))
62+
#expect(!output.contains("clip.xyz"))
63+
}
4264
}

0 commit comments

Comments
 (0)