MCPcopy Create free account
hub / github.com/angular/components / createTestComponentWithTrackyByTable

Function createTestComponentWithTrackyByTable

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

Source from the content-addressed store, hash-verified

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

Callers 1

table.spec.tsFile · 0.85

Calls 3

toStringMethod · 0.80
getRowsFunction · 0.70
getAttributeMethod · 0.65

Tested by

no test coverage detected