6
6
* found in the LICENSE file at https://angular.io/license
7
7
*/
8
8
import { FlatTreeControl , NestedTreeControl , TreeControl } from '@angular/cdk/tree' ;
9
- import { provideZoneChangeDetection , Component , ViewChild , Type } from '@angular/core' ;
9
+ import { Component , ViewChild , Type } from '@angular/core' ;
10
10
import { ComponentFixture , TestBed } from '@angular/core/testing' ;
11
11
import { BehaviorSubject , Observable } from 'rxjs' ;
12
12
import { map } from 'rxjs/operators' ;
@@ -28,7 +28,6 @@ describe('MatTree', () => {
28
28
function configureMatTreeTestingModule ( declarations : Type < any > [ ] ) {
29
29
TestBed . configureTestingModule ( {
30
30
imports : [ MatTreeModule ] ,
31
- providers : [ provideZoneChangeDetection ( ) ] ,
32
31
declarations : declarations ,
33
32
} ) . compileComponents ( ) ;
34
33
}
@@ -64,6 +63,32 @@ describe('MatTree', () => {
64
63
} ) ;
65
64
} ) ;
66
65
66
+ it ( 'with the right aria-level attrs' , ( ) => {
67
+ // add a child to the first node
68
+ const data = underlyingDataSource . data ;
69
+ underlyingDataSource . addChild ( data [ 2 ] ) ;
70
+ component . treeControl . expandAll ( ) ;
71
+ fixture . detectChanges ( ) ;
72
+
73
+ const ariaLevels = getNodes ( treeElement ) . map ( n => n . getAttribute ( 'aria-level' ) ) ;
74
+ expect ( ariaLevels ) . toEqual ( [ '1' , '1' , '1' , '2' ] ) ;
75
+ } ) ;
76
+
77
+ it ( 'with the right aria-expanded attrs' , ( ) => {
78
+ // add a child to the first node
79
+ const data = underlyingDataSource . data ;
80
+ underlyingDataSource . addChild ( data [ 2 ] ) ;
81
+ fixture . detectChanges ( ) ;
82
+ let ariaExpandedStates = getNodes ( treeElement ) . map ( n => n . getAttribute ( 'aria-expanded' ) ) ;
83
+ expect ( ariaExpandedStates ) . toEqual ( [ null , null , 'false' ] ) ;
84
+
85
+ component . treeControl . expandAll ( ) ;
86
+ fixture . detectChanges ( ) ;
87
+
88
+ ariaExpandedStates = getNodes ( treeElement ) . map ( n => n . getAttribute ( 'aria-expanded' ) ) ;
89
+ expect ( ariaExpandedStates ) . toEqual ( [ null , null , 'true' , null ] ) ;
90
+ } ) ;
91
+
67
92
it ( 'with the right data' , ( ) => {
68
93
expect ( underlyingDataSource . data . length ) . toBe ( 3 ) ;
69
94
@@ -608,6 +633,7 @@ describe('MatTree', () => {
608
633
609
634
it ( 'ignores clicks on disabled items' , ( ) => {
610
635
underlyingDataSource . data [ 1 ] . isDisabled = true ;
636
+ fixture . changeDetectorRef . markForCheck ( ) ;
611
637
fixture . detectChanges ( ) ;
612
638
613
639
// attempt to click on the first child
0 commit comments