(trackByStrategy: string)
| 1777 | |
| 1778 | describe('with trackBy', () => { |
| 1779 | function createTestComponentWithTrackyByTable(trackByStrategy: string) { |
| 1780 | fixture = TestBed.createComponent(TrackByCdkTableApp); |
| 1781 | |
| 1782 | component = fixture.componentInstance; |
| 1783 | component.trackByStrategy = trackByStrategy; |
| 1784 | |
| 1785 | tableElement = fixture.nativeElement.querySelector('cdk-table'); |
| 1786 | fixture.detectChanges(); |
| 1787 | |
| 1788 | // Each row receives an attribute 'initialIndex' the element's original place |
| 1789 | getRows(tableElement).forEach((row: Element, index: number) => { |
| 1790 | row.setAttribute('initialIndex', index.toString()); |
| 1791 | }); |
| 1792 | |
| 1793 | // Prove that the attributes match their indicies |
| 1794 | const initialRows = getRows(tableElement); |
| 1795 | expect(initialRows[0].getAttribute('initialIndex')).toBe('0'); |
| 1796 | expect(initialRows[1].getAttribute('initialIndex')).toBe('1'); |
| 1797 | expect(initialRows[2].getAttribute('initialIndex')).toBe('2'); |
| 1798 | } |
| 1799 | |
| 1800 | // Swap first two elements, remove the third, add new data |
| 1801 | function mutateData() { |
no test coverage detected