1
1
import { async , TestBed , ComponentFixture , inject } from '@angular/core/testing' ;
2
- import { Component , DebugElement } from '@angular/core' ;
2
+ import { Component , DebugElement , ViewChildren } from '@angular/core' ;
3
3
import { By } from '@angular/platform-browser' ;
4
4
import { MdSelectionList , MdListOption , MdListModule } from './index' ;
5
5
import { createKeyboardEvent } from '@angular/cdk/testing' ;
@@ -51,11 +51,13 @@ describe('test normal selection list with list option', () => {
51
51
let selectList = selectionList . injector . get < MdSelectionList > ( MdSelectionList ) . selectedOptions ;
52
52
53
53
expect ( selectList . selected . length ) . toBe ( 0 ) ;
54
+ expect ( listOption [ 2 ] . nativeElement . getAttribute ( 'aria-selected' ) ) . toBe ( 'false' ) ;
54
55
55
56
testListItem . toggle ( ) ;
56
57
fixture . detectChanges ( ) ;
57
58
58
59
expect ( listOption [ 2 ] . nativeElement . getAttribute ( 'aria-selected' ) ) . toBe ( 'true' ) ;
60
+ expect ( listOption [ 2 ] . nativeElement . getAttribute ( 'aria-disabled' ) ) . toBe ( 'false' ) ;
59
61
expect ( selectList . selected . length ) . toBe ( 1 ) ;
60
62
} ) ;
61
63
@@ -65,6 +67,8 @@ describe('test normal selection list with list option', () => {
65
67
let selectList = selectionList . injector . get < MdSelectionList > ( MdSelectionList ) . selectedOptions ;
66
68
67
69
expect ( selectList . selected . length ) . toBe ( 0 ) ;
70
+ expect ( listOption [ 2 ] . nativeElement . getAttribute ( 'aria-selected' ) ) . toBe ( 'false' ) ;
71
+ expect ( listOption [ 1 ] . nativeElement . getAttribute ( 'aria-selected' ) ) . toBe ( 'false' ) ;
68
72
69
73
testListItem . toggle ( ) ;
70
74
fixture . detectChanges ( ) ;
@@ -75,6 +79,8 @@ describe('test normal selection list with list option', () => {
75
79
expect ( selectList . selected . length ) . toBe ( 2 ) ;
76
80
expect ( listOption [ 2 ] . nativeElement . getAttribute ( 'aria-selected' ) ) . toBe ( 'true' ) ;
77
81
expect ( listOption [ 1 ] . nativeElement . getAttribute ( 'aria-selected' ) ) . toBe ( 'true' ) ;
82
+ expect ( listOption [ 1 ] . nativeElement . getAttribute ( 'aria-disabled' ) ) . toBe ( 'false' ) ;
83
+ expect ( listOption [ 2 ] . nativeElement . getAttribute ( 'aria-disabled' ) ) . toBe ( 'false' ) ;
78
84
} ) ;
79
85
80
86
it ( 'should be able to deselect an option' , ( ) => {
@@ -107,6 +113,17 @@ describe('test normal selection list with list option', () => {
107
113
expect ( selectList . selected . length ) . toBe ( 0 ) ;
108
114
} ) ;
109
115
116
+ it ( 'should be able to un-disable disabled items' , ( ) => {
117
+ let testListItem = listOption [ 0 ] . injector . get < MdListOption > ( MdListOption ) ;
118
+
119
+ expect ( listOption [ 0 ] . nativeElement . getAttribute ( 'aria-disabled' ) ) . toBe ( 'true' ) ;
120
+
121
+ testListItem . disabled = false ;
122
+ fixture . detectChanges ( ) ;
123
+
124
+ expect ( listOption [ 0 ] . nativeElement . getAttribute ( 'aria-disabled' ) ) . toBe ( 'false' ) ;
125
+ } ) ;
126
+
110
127
it ( 'should be able to use keyboard select with SPACE' , ( ) => {
111
128
let testListItem = listOption [ 1 ] . nativeElement as HTMLElement ;
112
129
let SPACE_EVENT : KeyboardEvent =
@@ -202,7 +219,7 @@ describe('test selection list with single option', () => {
202
219
fixture . detectChanges ( ) ;
203
220
204
221
expect ( listItemEl . nativeElement ) . toBe ( document . activeElement ) ;
205
- if ( ! platform . IS_TRIDENT ) {
222
+ if ( ! platform . TRIDENT ) {
206
223
expect ( listItemEl . nativeElement . className ) . toContain ( 'mat-list-item-focus' ) ;
207
224
}
208
225
0 commit comments