MCPcopy Index your code
hub / github.com/angular/components / createTestComponentWithTrackyByTable

Function createTestComponentWithTrackyByTable

src/cdk/table/table.spec.ts:1738–1757  ·  view source on GitHub ↗
(trackByStrategy: string)

Source from the content-addressed store, hash-verified

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() {

Callers 1

table.spec.tsFile · 0.85

Calls 3

toStringMethod · 0.80
getRowsFunction · 0.70
getAttributeMethod · 0.65

Tested by

no test coverage detected