@@ -13,7 +13,6 @@ import {
1313 Type ,
1414 ViewChild ,
1515 inject ,
16- TrackByFunction ,
1716} from '@angular/core' ;
1817import { By } from '@angular/platform-browser' ;
1918import { ComponentFixture , TestBed , fakeAsync , flush , waitForAsync } from '@angular/core/testing' ;
@@ -1996,35 +1995,6 @@ describe('CdkTable', () => {
19961995 expect ( noDataRow ) . toBeTruthy ( ) ;
19971996 expect ( noDataRow . getAttribute ( 'colspan' ) ) . toEqual ( '3' ) ;
19981997 } ) ;
1999-
2000- it ( 'should properly update table content when data changes in OnPush component with track by instance' , ( ) => {
2001- setupTableTestApp ( WrapNativeTrackByHtmlTableAppOnPush ) ;
2002-
2003- const data = component . dataSource . data ;
2004-
2005- expectTableToMatchContent ( tableElement , [
2006- [ 'Column A' , 'Column B' , 'Column C' ] ,
2007- [ data [ 0 ] . a , data [ 0 ] . b , data [ 0 ] . c ] ,
2008- [ data [ 1 ] . a , data [ 1 ] . b , data [ 1 ] . c ] ,
2009- [ data [ 2 ] . a , data [ 2 ] . b , data [ 2 ] . c ] ,
2010- ] ) ;
2011-
2012- component . dataSource . data = component . dataSource . data . map ( ( data : TestData ) => ( {
2013- ...data ,
2014- b : `${ data . b } -updated` ,
2015- } ) ) ;
2016-
2017- fixture . detectChanges ( ) ;
2018-
2019- const newData = component . dataSource . data ;
2020-
2021- expectTableToMatchContent ( tableElement , [
2022- [ 'Column A' , 'Column B' , 'Column C' ] ,
2023- [ newData [ 0 ] . a , newData [ 0 ] . b , newData [ 0 ] . c ] ,
2024- [ newData [ 1 ] . a , newData [ 1 ] . b , newData [ 1 ] . c ] ,
2025- [ newData [ 2 ] . a , newData [ 2 ] . b , newData [ 2 ] . c ] ,
2026- ] ) ;
2027- } ) ;
20281998} ) ;
20291999
20302000interface TestData {
@@ -3165,7 +3135,7 @@ class TableWithIndirectDescendantDefs {
31653135@Component ( {
31663136 selector : 'cdk-table-change-detection-on-push' ,
31673137 template : `
3168- <table cdk-table [dataSource]="dataSource" [trackBy]="trackBy" >
3138+ <table cdk-table [dataSource]="dataSource">
31693139 <ng-container cdkColumnDef="column_a">
31703140 <th cdk-header-cell *cdkHeaderCellDef> Column A</th>
31713141 <td cdk-cell *cdkCellDef="let row"> {{row.a}}</td>
@@ -3193,7 +3163,6 @@ class TableWithIndirectDescendantDefs {
31933163} )
31943164class NativeHtmlTableAppOnPush {
31953165 @Input ( ) dataSource : Observable < TestData [ ] > | null = null ;
3196- @Input ( ) trackBy : TrackByFunction < TestData > | undefined ;
31973166 columnsToRender = [ 'column_a' , 'column_b' , 'column_c' ] ;
31983167}
31993168
@@ -3207,17 +3176,6 @@ class WrapNativeHtmlTableAppOnPush {
32073176 dataSource : FakeDataSource = new FakeDataSource ( ) ;
32083177}
32093178
3210- @Component ( {
3211- template : `
3212- <cdk-table-change-detection-on-push [dataSource]="dataSource" [trackBy]="trackBy"></cdk-table-change-detection-on-push>
3213- ` ,
3214- imports : [ NativeHtmlTableAppOnPush ] ,
3215- } )
3216- class WrapNativeTrackByHtmlTableAppOnPush {
3217- dataSource : FakeDataSource = new FakeDataSource ( ) ;
3218- trackBy : TrackByFunction < TestData > = ( index : number , data : TestData ) => data . a ;
3219- }
3220-
32213179function getElements ( element : Element , query : string ) : HTMLElement [ ] {
32223180 return [ ] . slice . call ( element . querySelectorAll ( query ) ) ;
32233181}
0 commit comments