(trackByStrategy: 'reference' | 'property' | 'index')
| 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 |
no test coverage detected
searching dependent graphs…