@@ -327,6 +327,16 @@ describe('CdkTable', () => {
327
327
] ) ;
328
328
} ) ;
329
329
330
+ it ( 'should be able to project a caption' , fakeAsync ( ( ) => {
331
+ setupTableTestApp ( NativeHtmlTableWithCaptionApp ) ;
332
+ fixture . detectChanges ( ) ;
333
+
334
+ const caption = tableElement . querySelector ( 'caption' ) ;
335
+
336
+ expect ( caption ) . toBeTruthy ( ) ;
337
+ expect ( tableElement . firstElementChild ) . toBe ( caption ) ;
338
+ } ) ) ;
339
+
330
340
describe ( 'with different data inputs other than data source' , ( ) => {
331
341
let baseData : TestData [ ] = [
332
342
{ a : 'a_1' , b : 'b_1' , c : 'c_1' } ,
@@ -2182,6 +2192,27 @@ class NativeHtmlTableApp {
2182
2192
@ViewChild ( CdkTable ) table : CdkTable < TestData > ;
2183
2193
}
2184
2194
2195
+ @Component ( {
2196
+ template : `
2197
+ <table cdk-table [dataSource]="dataSource">
2198
+ <caption>Very important data</caption>
2199
+ <ng-container cdkColumnDef="column_a">
2200
+ <th cdk-header-cell *cdkHeaderCellDef> Column A</th>
2201
+ <td cdk-cell *cdkCellDef="let row"> {{row.a}}</td>
2202
+ </ng-container>
2203
+
2204
+ <tr cdk-header-row *cdkHeaderRowDef="columnsToRender"></tr>
2205
+ <tr cdk-row *cdkRowDef="let row; columns: columnsToRender" class="customRowClass"></tr>
2206
+ </table>
2207
+ `
2208
+ } )
2209
+ class NativeHtmlTableWithCaptionApp {
2210
+ dataSource : FakeDataSource | undefined = new FakeDataSource ( ) ;
2211
+ columnsToRender = [ 'column_a' ] ;
2212
+
2213
+ @ViewChild ( CdkTable ) table : CdkTable < TestData > ;
2214
+ }
2215
+
2185
2216
function getElements ( element : Element , query : string ) : Element [ ] {
2186
2217
return [ ] . slice . call ( element . querySelectorAll ( query ) ) ;
2187
2218
}
0 commit comments