@@ -18,4 +18,67 @@ class TableTests: IgniteTestSuite {
1818 let output = element. markupString ( )
1919 #expect( output == " <table class= \" table \" ><tbody></tbody></table> " )
2020 }
21+
22+ @Test ( " Table with header renders thead " )
23+ func tableWithHeader( ) async throws {
24+ let element = Table {
25+ Row {
26+ Column { " A " }
27+ Column { " B " }
28+ }
29+ } header: {
30+ " Name "
31+ " Value "
32+ }
33+ let output = element. markupString ( )
34+ #expect( output. contains ( " <thead><tr><th>Name</th><th>Value</th></tr></thead> " ) )
35+ }
36+
37+ @Test ( " Table with rows renders content inside tbody " )
38+ func tableWithRows( ) async throws {
39+ let element = Table {
40+ Row {
41+ Column { " Cell1 " }
42+ }
43+ }
44+ let output = element. markupString ( )
45+ #expect( output. contains ( " <tbody> " ) )
46+ #expect( output. contains ( " Cell1 " ) )
47+ }
48+
49+ @Test ( " Striped rows style adds table-striped class " )
50+ func stripedRowsStyle( ) async throws {
51+ let element = Table { } . tableStyle ( . stripedRows)
52+ let output = element. markupString ( )
53+ #expect( output. contains ( " table-striped " ) )
54+ #expect( !output. contains ( " table-striped-columns " ) )
55+ }
56+
57+ @Test ( " Striped columns style adds table-striped-columns class " )
58+ func stripedColumnsStyle( ) async throws {
59+ let element = Table { } . tableStyle ( . stripedColumns)
60+ let output = element. markupString ( )
61+ #expect( output. contains ( " table-striped-columns " ) )
62+ }
63+
64+ @Test ( " Plain style adds no striping class " )
65+ func plainStyle( ) async throws {
66+ let element = Table { } . tableStyle ( . plain)
67+ let output = element. markupString ( )
68+ #expect( !output. contains ( " table-striped " ) )
69+ }
70+
71+ @Test ( " Table border adds table-bordered class " )
72+ func tableBorder( ) async throws {
73+ let element = Table { } . tableBorder ( true )
74+ let output = element. markupString ( )
75+ #expect( output. contains ( " table-bordered " ) )
76+ }
77+
78+ @Test ( " Accessibility label adds caption element " )
79+ func accessibilityLabel( ) async throws {
80+ let element = Table { } . accessibilityLabel ( " Test caption " )
81+ let output = element. markupString ( )
82+ #expect( output. contains ( " <caption>Test caption</caption> " ) )
83+ }
2184}
0 commit comments