@@ -37,7 +37,8 @@ describe('CdkTable', () => {
37
37
UndefinedColumnsCdkTableApp ,
38
38
WhenRowCdkTableApp ,
39
39
WhenRowWithoutDefaultCdkTableApp ,
40
- WhenRowMultipleDefaultsCdkTableApp
40
+ WhenRowMultipleDefaultsCdkTableApp ,
41
+ BooleanRowCdkTableApp
41
42
] ,
42
43
} ) . compileComponents ( ) ;
43
44
} ) ) ;
@@ -106,6 +107,21 @@ describe('CdkTable', () => {
106
107
} ) ;
107
108
} ) ;
108
109
110
+ it ( 'should render cells even if row data is falsy' , ( ) => {
111
+ const booleanRowCdkTableAppFixture = TestBed . createComponent ( BooleanRowCdkTableApp ) ;
112
+ const booleanRowCdkTableElement =
113
+ booleanRowCdkTableAppFixture . nativeElement . querySelector ( 'cdk-table' ) ;
114
+ booleanRowCdkTableAppFixture . detectChanges ( ) ;
115
+
116
+ expectTableToMatchContent ( booleanRowCdkTableElement , [
117
+ [ '' ] , // Header row
118
+ [ 'false' ] , // Data rows
119
+ [ 'true' ] ,
120
+ [ 'false' ] ,
121
+ [ 'true' ] ,
122
+ ] ) ;
123
+ } ) ;
124
+
109
125
it ( 'should be able to apply class-friendly css class names for the column cells' , ( ) => {
110
126
const crazyColumnNameAppFixture = TestBed . createComponent ( CrazyColumnNameCdkTableApp ) ;
111
127
const crazyColumnNameTableElement =
@@ -636,6 +652,16 @@ class FakeDataSource extends DataSource<TestData> {
636
652
}
637
653
}
638
654
655
+ class BooleanDataSource extends DataSource < boolean > {
656
+ _dataChange = new BehaviorSubject < boolean [ ] > ( [ false , true , false , true ] ) ;
657
+
658
+ connect ( ) : Observable < boolean [ ] > {
659
+ return this . _dataChange ;
660
+ }
661
+
662
+ disconnect ( ) { }
663
+ }
664
+
639
665
@Component ( {
640
666
template : `
641
667
<cdk-table [dataSource]="dataSource">
@@ -668,6 +694,23 @@ class SimpleCdkTableApp {
668
694
@ViewChild ( CdkTable ) table : CdkTable < TestData > ;
669
695
}
670
696
697
+ @Component ( {
698
+ template : `
699
+ <cdk-table [dataSource]="dataSource">
700
+ <ng-container cdkColumnDef="column_a">
701
+ <cdk-header-cell *cdkHeaderCellDef></cdk-header-cell>
702
+ <cdk-cell *cdkCellDef="let data"> {{data}} </cdk-cell>
703
+ </ng-container>
704
+
705
+ <cdk-header-row *cdkHeaderRowDef="['column_a']"></cdk-header-row>
706
+ <cdk-row *cdkRowDef="let row; columns: ['column_a']"></cdk-row>
707
+ </cdk-table>
708
+ `
709
+ } )
710
+ class BooleanRowCdkTableApp {
711
+ dataSource = new BooleanDataSource ( ) ;
712
+ }
713
+
671
714
@Component ( {
672
715
template : `
673
716
<cdk-table [dataSource]="dataSource">
0 commit comments