(trackByStrategy: string)
| 1736 | |
| 1737 | describe('with trackBy', () => { |
| 1738 | function createTestComponentWithTrackyByTable(trackByStrategy: string) { |
| 1739 | fixture = TestBed.createComponent(TrackByCdkTableApp); |
| 1740 | |
| 1741 | component = fixture.componentInstance; |
| 1742 | component.trackByStrategy = trackByStrategy; |
| 1743 | |
| 1744 | tableElement = fixture.nativeElement.querySelector('cdk-table'); |
| 1745 | fixture.detectChanges(); |
| 1746 | |
| 1747 | // Each row receives an attribute 'initialIndex' the element's original place |
| 1748 | getRows(tableElement).forEach((row: Element, index: number) => { |
| 1749 | row.setAttribute('initialIndex', index.toString()); |
| 1750 | }); |
| 1751 | |
| 1752 | // Prove that the attributes match their indicies |
| 1753 | const initialRows = getRows(tableElement); |
| 1754 | expect(initialRows[0].getAttribute('initialIndex')).toBe('0'); |
| 1755 | expect(initialRows[1].getAttribute('initialIndex')).toBe('1'); |
| 1756 | expect(initialRows[2].getAttribute('initialIndex')).toBe('2'); |
| 1757 | } |
| 1758 | |
| 1759 | // Swap first two elements, remove the third, add new data |
| 1760 | function mutateData() { |
no test coverage detected