1
1
import { ComponentFixture , fakeAsync , TestBed , tick , waitForAsync } from '@angular/core/testing' ;
2
2
import { Component , DebugElement , ViewChild } from '@angular/core' ;
3
3
import { By } from '@angular/platform-browser' ;
4
- import { CdkListbox , CdkListboxModule , CdkOption , ListboxSelectionChangeEvent } from './index' ;
4
+ import { CdkListbox , CdkListboxModule , CdkOption , ListboxValueChangeEvent } from './index' ;
5
5
import {
6
6
createKeyboardEvent ,
7
7
dispatchKeyboardEvent ,
@@ -114,17 +114,17 @@ describe('CdkOption and CdkListbox', () => {
114
114
listboxInstance . setActiveOption ( optionInstances [ 1 ] ) ;
115
115
fixture . detectChanges ( ) ;
116
116
117
- expect ( listboxInstance . _listKeyManager . activeItem ) . toBe ( optionInstances [ 1 ] ) ;
117
+ expect ( listboxInstance . listKeyManager . activeItem ) . toBe ( optionInstances [ 1 ] ) ;
118
118
119
119
dispatchKeyboardEvent ( listboxElement , 'keydown' , HOME ) ;
120
120
fixture . detectChanges ( ) ;
121
121
122
- expect ( listboxInstance . _listKeyManager . activeItem ) . toBe ( optionInstances [ 0 ] ) ;
122
+ expect ( listboxInstance . listKeyManager . activeItem ) . toBe ( optionInstances [ 0 ] ) ;
123
123
124
124
dispatchKeyboardEvent ( listboxElement , 'keydown' , END ) ;
125
125
fixture . detectChanges ( ) ;
126
126
127
- expect ( listboxInstance . _listKeyManager . activeItem ) . toBe ( optionInstances [ 3 ] ) ;
127
+ expect ( listboxInstance . listKeyManager . activeItem ) . toBe ( optionInstances [ 3 ] ) ;
128
128
} ) ;
129
129
130
130
it ( 'should be able to toggle listbox disabled state' , ( ) => {
@@ -210,15 +210,15 @@ describe('CdkOption and CdkListbox', () => {
210
210
} ) ;
211
211
212
212
it ( 'should change active item using type ahead' , fakeAsync ( ( ) => {
213
- expect ( listboxInstance . _listKeyManager . activeItem ) . toBeNull ( ) ;
214
- expect ( listboxInstance . _listKeyManager . activeItemIndex ) . toBe ( - 1 ) ;
213
+ expect ( listboxInstance . listKeyManager . activeItem ) . toBeNull ( ) ;
214
+ expect ( listboxInstance . listKeyManager . activeItemIndex ) . toBe ( - 1 ) ;
215
215
216
216
dispatchKeyboardEvent ( listboxElement , 'keydown' , A ) ;
217
217
fixture . detectChanges ( ) ;
218
218
tick ( 200 ) ;
219
219
220
- expect ( listboxInstance . _listKeyManager . activeItem ) . toEqual ( optionInstances [ 2 ] ) ;
221
- expect ( listboxInstance . _listKeyManager . activeItemIndex ) . toBe ( 2 ) ;
220
+ expect ( listboxInstance . listKeyManager . activeItem ) . toEqual ( optionInstances [ 2 ] ) ;
221
+ expect ( listboxInstance . listKeyManager . activeItemIndex ) . toBe ( 2 ) ;
222
222
} ) ) ;
223
223
224
224
it ( 'should not handle space or enter on a disabled listbox' , ( ) => {
@@ -240,8 +240,8 @@ describe('CdkOption and CdkListbox', () => {
240
240
} ) ;
241
241
242
242
it ( 'should not handle type ahead on a disabled listbox' , fakeAsync ( ( ) => {
243
- expect ( listboxInstance . _listKeyManager . activeItem ) . toBeNull ( ) ;
244
- expect ( listboxInstance . _listKeyManager . activeItemIndex ) . toBe ( - 1 ) ;
243
+ expect ( listboxInstance . listKeyManager . activeItem ) . toBeNull ( ) ;
244
+ expect ( listboxInstance . listKeyManager . activeItemIndex ) . toBe ( - 1 ) ;
245
245
246
246
testComponent . isListboxDisabled = true ;
247
247
fixture . detectChanges ( ) ;
@@ -250,8 +250,8 @@ describe('CdkOption and CdkListbox', () => {
250
250
fixture . detectChanges ( ) ;
251
251
tick ( 200 ) ;
252
252
253
- expect ( listboxInstance . _listKeyManager . activeItem ) . toBeNull ( ) ;
254
- expect ( listboxInstance . _listKeyManager . activeItemIndex ) . toBe ( - 1 ) ;
253
+ expect ( listboxInstance . listKeyManager . activeItem ) . toBeNull ( ) ;
254
+ expect ( listboxInstance . listKeyManager . activeItemIndex ) . toBe ( - 1 ) ;
255
255
} ) ) ;
256
256
257
257
it ( 'should not select a disabled option using space or enter' , ( ) => {
@@ -273,38 +273,38 @@ describe('CdkOption and CdkListbox', () => {
273
273
} ) ;
274
274
275
275
it ( 'should update active item upon arrow key presses' , ( ) => {
276
- expect ( listboxInstance . _listKeyManager . activeItem ) . toBeNull ( ) ;
277
- expect ( listboxInstance . _listKeyManager . activeItemIndex ) . toBe ( - 1 ) ;
276
+ expect ( listboxInstance . listKeyManager . activeItem ) . toBeNull ( ) ;
277
+ expect ( listboxInstance . listKeyManager . activeItemIndex ) . toBe ( - 1 ) ;
278
278
279
279
dispatchKeyboardEvent ( listboxElement , 'keydown' , DOWN_ARROW ) ;
280
280
fixture . detectChanges ( ) ;
281
281
282
- expect ( listboxInstance . _listKeyManager . activeItem ) . toEqual ( optionInstances [ 0 ] ) ;
283
- expect ( listboxInstance . _listKeyManager . activeItemIndex ) . toBe ( 0 ) ;
282
+ expect ( listboxInstance . listKeyManager . activeItem ) . toEqual ( optionInstances [ 0 ] ) ;
283
+ expect ( listboxInstance . listKeyManager . activeItemIndex ) . toBe ( 0 ) ;
284
284
285
285
dispatchKeyboardEvent ( listboxElement , 'keydown' , DOWN_ARROW ) ;
286
286
fixture . detectChanges ( ) ;
287
287
288
- expect ( listboxInstance . _listKeyManager . activeItem ) . toEqual ( optionInstances [ 1 ] ) ;
289
- expect ( listboxInstance . _listKeyManager . activeItemIndex ) . toBe ( 1 ) ;
288
+ expect ( listboxInstance . listKeyManager . activeItem ) . toEqual ( optionInstances [ 1 ] ) ;
289
+ expect ( listboxInstance . listKeyManager . activeItemIndex ) . toBe ( 1 ) ;
290
290
} ) ;
291
291
292
292
it ( 'should skip disabled options when navigating with arrow keys' , ( ) => {
293
- expect ( listboxInstance . _listKeyManager . activeItem ) . toBeNull ( ) ;
294
- expect ( listboxInstance . _listKeyManager . activeItemIndex ) . toBe ( - 1 ) ;
293
+ expect ( listboxInstance . listKeyManager . activeItem ) . toBeNull ( ) ;
294
+ expect ( listboxInstance . listKeyManager . activeItemIndex ) . toBe ( - 1 ) ;
295
295
296
296
testComponent . isSolarDisabled = true ;
297
297
dispatchKeyboardEvent ( listboxElement , 'keydown' , DOWN_ARROW ) ;
298
298
fixture . detectChanges ( ) ;
299
299
300
- expect ( listboxInstance . _listKeyManager . activeItem ) . toEqual ( optionInstances [ 0 ] ) ;
301
- expect ( listboxInstance . _listKeyManager . activeItemIndex ) . toBe ( 0 ) ;
300
+ expect ( listboxInstance . listKeyManager . activeItem ) . toEqual ( optionInstances [ 0 ] ) ;
301
+ expect ( listboxInstance . listKeyManager . activeItemIndex ) . toBe ( 0 ) ;
302
302
303
303
dispatchKeyboardEvent ( listboxElement , 'keydown' , DOWN_ARROW ) ;
304
304
fixture . detectChanges ( ) ;
305
305
306
- expect ( listboxInstance . _listKeyManager . activeItem ) . toEqual ( optionInstances [ 2 ] ) ;
307
- expect ( listboxInstance . _listKeyManager . activeItemIndex ) . toBe ( 2 ) ;
306
+ expect ( listboxInstance . listKeyManager . activeItem ) . toEqual ( optionInstances [ 2 ] ) ;
307
+ expect ( listboxInstance . listKeyManager . activeItemIndex ) . toBe ( 2 ) ;
308
308
} ) ;
309
309
310
310
it ( 'should update selected option on click event' , ( ) => {
@@ -903,7 +903,7 @@ class ListboxWithOptions {
903
903
isPurpleDisabled : boolean = false ;
904
904
isSolarDisabled : boolean = false ;
905
905
906
- onSelectionChange ( event : ListboxSelectionChangeEvent < unknown > ) {
906
+ onSelectionChange ( event : ListboxValueChangeEvent < unknown > ) {
907
907
this . changedOption = event . option ;
908
908
}
909
909
}
@@ -923,7 +923,7 @@ class ListboxMultiselect {
923
923
changedOption : CdkOption ;
924
924
isMultiselectable : boolean = false ;
925
925
926
- onSelectionChange ( event : ListboxSelectionChangeEvent < unknown > ) {
926
+ onSelectionChange ( event : ListboxValueChangeEvent < unknown > ) {
927
927
this . changedOption = event . option ;
928
928
}
929
929
}
@@ -943,7 +943,7 @@ class ListboxActiveDescendant {
943
943
isActiveDescendant : boolean = true ;
944
944
focusedOption : string ;
945
945
946
- onSelectionChange ( event : ListboxSelectionChangeEvent < unknown > ) {
946
+ onSelectionChange ( event : ListboxValueChangeEvent < unknown > ) {
947
947
this . changedOption = event . option ;
948
948
}
949
949
@@ -974,7 +974,7 @@ class ListboxControlValueAccessor {
974
974
showListbox : boolean = true ;
975
975
@ViewChild ( CdkListbox ) listbox : CdkListbox < string > ;
976
976
977
- onSelectionChange ( event : ListboxSelectionChangeEvent < string > ) {
977
+ onSelectionChange ( event : ListboxValueChangeEvent < string > ) {
978
978
this . changedOption = event . option ;
979
979
}
980
980
}
@@ -1007,7 +1007,7 @@ class ListboxInsideCombobox {
1007
1007
@ViewChild ( CdkListbox ) listbox : CdkListbox < string > ;
1008
1008
@ViewChild ( CdkCombobox ) combobox : CdkCombobox ;
1009
1009
1010
- onSelectionChange ( event : ListboxSelectionChangeEvent < string > ) {
1010
+ onSelectionChange ( event : ListboxValueChangeEvent < string > ) {
1011
1011
this . changedOption = event . option ;
1012
1012
}
1013
1013
}
0 commit comments