@@ -327,6 +327,16 @@ describe('CdkTable', () => {
327327 ] ) ;
328328 } ) ;
329329
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+
330340 describe ( 'with different data inputs other than data source' , ( ) => {
331341 let baseData : TestData [ ] = [
332342 { a : 'a_1' , b : 'b_1' , c : 'c_1' } ,
@@ -2182,6 +2192,27 @@ class NativeHtmlTableApp {
21822192 @ViewChild ( CdkTable ) table : CdkTable < TestData > ;
21832193}
21842194
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+
21852216function getElements ( element : Element , query : string ) : Element [ ] {
21862217 return [ ] . slice . call ( element . querySelectorAll ( query ) ) ;
21872218}
0 commit comments