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

Function createTrackByTestComponent

src/cdk/tree/tree.spec.ts:543–563  ·  view source on GitHub ↗
(trackByStrategy: 'reference' | 'property' | 'index')

Source from the content-addressed store, hash-verified

541 let component: CdkTreeAppWithTrackBy;
542
543 function createTrackByTestComponent(trackByStrategy: 'reference' | 'property' | 'index') {
544 fixture = TestBed.createComponent(CdkTreeAppWithTrackBy);
545 component = fixture.componentInstance;
546 component.trackByStrategy = trackByStrategy;
547 fixture.detectChanges();
548
549 dataSource = component.dataSource as FakeDataSource;
550 tree = component.tree;
551 treeElement = fixture.nativeElement.querySelector('cdk-tree');
552
553 // Each node receives an attribute 'initialIndex' the element's original place
554 getNodes(treeElement).forEach((node: Element, index: number) => {
555 node.setAttribute('initialIndex', index.toString());
556 });
557
558 // Prove that the attributes match their indices
559 const initialNodes = getNodes(treeElement);
560 expect(initialNodes[0].getAttribute('initialIndex')).toBe('0');
561 expect(initialNodes[1].getAttribute('initialIndex')).toBe('1');
562 expect(initialNodes[2].getAttribute('initialIndex')).toBe('2');
563 }
564
565 function mutateData() {
566 // Swap first and second data in data array

Callers 1

tree.spec.tsFile · 0.70

Calls 4

toStringMethod · 0.80
getNodesFunction · 0.70
getAttributeMethod · 0.65
addChildMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…