1+ import { DOWN_ARROW , ENTER , UP_ARROW } from '@angular/cdk/keycodes' ;
12import { Component , QueryList , ViewChild } from '@angular/core' ;
23import { async , fakeAsync , TestBed } from '@angular/core/testing' ;
34import { By } from '@angular/platform-browser' ;
@@ -136,7 +137,7 @@ describe('nz-select option container', () => {
136137 const ul = oc . nativeElement . querySelector ( '.ant-select-dropdown-menu' ) ;
137138 fixture . detectChanges ( ) ;
138139 fixture . whenStable ( ) . then ( ( ) => {
139- dispatchKeyboardEvent ( ul , 'keydown' , 38 ) ;
140+ dispatchKeyboardEvent ( ul , 'keydown' , UP_ARROW ) ;
140141 fixture . detectChanges ( ) ;
141142 expect ( oc . nativeElement . querySelector ( '.ant-select-dropdown-menu-item-active' ) . innerText ) . toBe ( 'sub2-3' ) ;
142143 } ) ;
@@ -146,8 +147,8 @@ describe('nz-select option container', () => {
146147 const ul = oc . nativeElement . querySelector ( '.ant-select-dropdown-menu' ) ;
147148 fixture . detectChanges ( ) ;
148149 fixture . whenStable ( ) . then ( ( ) => {
149- dispatchKeyboardEvent ( ul , 'keydown' , 40 ) ;
150- dispatchKeyboardEvent ( ul , 'keydown' , 40 ) ;
150+ dispatchKeyboardEvent ( ul , 'keydown' , DOWN_ARROW ) ;
151+ dispatchKeyboardEvent ( ul , 'keydown' , DOWN_ARROW ) ;
151152 fixture . detectChanges ( ) ;
152153 expect ( oc . nativeElement . querySelector ( '.ant-select-dropdown-menu-item-active' ) . innerText ) . toBe ( 'test2' ) ;
153154 } ) ;
@@ -157,7 +158,7 @@ describe('nz-select option container', () => {
157158 const ul = oc . nativeElement . querySelector ( '.ant-select-dropdown-menu' ) ;
158159 fixture . detectChanges ( ) ;
159160 fixture . whenStable ( ) . then ( ( ) => {
160- dispatchKeyboardEvent ( ul , 'keydown' , 13 ) ;
161+ dispatchKeyboardEvent ( ul , 'keydown' , ENTER ) ;
161162 fixture . detectChanges ( ) ;
162163 expect ( testComponent . clickOption ) . toHaveBeenCalledTimes ( 1 ) ;
163164 expect ( testComponent . updateListOfSelectedValueFromOptionContainer ) . toHaveBeenCalledTimes ( 0 ) ;
@@ -168,10 +169,10 @@ describe('nz-select option container', () => {
168169 const ul = oc . nativeElement . querySelector ( '.ant-select-dropdown-menu' ) ;
169170 fixture . detectChanges ( ) ;
170171 fixture . whenStable ( ) . then ( ( ) => {
171- dispatchKeyboardEvent ( ul , 'keydown' , 40 ) ;
172- dispatchKeyboardEvent ( ul , 'keydown' , 40 ) ;
172+ dispatchKeyboardEvent ( ul , 'keydown' , DOWN_ARROW ) ;
173+ dispatchKeyboardEvent ( ul , 'keydown' , DOWN_ARROW ) ;
173174 fixture . detectChanges ( ) ;
174- dispatchKeyboardEvent ( ul , 'keydown' , 13 ) ;
175+ dispatchKeyboardEvent ( ul , 'keydown' , ENTER ) ;
175176 fixture . detectChanges ( ) ;
176177 expect ( testComponent . clickOption ) . toHaveBeenCalledTimes ( 1 ) ;
177178 expect ( testComponent . listOfSelectedValue [ 0 ] . value ) . toBe ( 'test2' ) ;
@@ -183,8 +184,8 @@ describe('nz-select option container', () => {
183184 const ul = oc . nativeElement . querySelector ( '.ant-select-dropdown-menu' ) ;
184185 fixture . detectChanges ( ) ;
185186 fixture . whenStable ( ) . then ( ( ) => {
186- dispatchKeyboardEvent ( ul , 'keydown' , 40 ) ;
187- dispatchKeyboardEvent ( ul , 'keydown' , 40 ) ;
187+ dispatchKeyboardEvent ( ul , 'keydown' , DOWN_ARROW ) ;
188+ dispatchKeyboardEvent ( ul , 'keydown' , DOWN_ARROW ) ;
188189 fixture . detectChanges ( ) ;
189190 expect ( oc . nativeElement . querySelector ( '.ant-select-dropdown-menu-item-active' ) . innerText ) . toBe ( 'test2' ) ;
190191 testComponent . nzOptionContainerComponent . resetActiveOption ( ) ;
@@ -197,8 +198,8 @@ describe('nz-select option container', () => {
197198 const ul = oc . nativeElement . querySelector ( '.ant-select-dropdown-menu' ) ;
198199 fixture . detectChanges ( ) ;
199200 fixture . whenStable ( ) . then ( ( ) => {
200- dispatchKeyboardEvent ( ul , 'keydown' , 40 ) ;
201- dispatchKeyboardEvent ( ul , 'keydown' , 40 ) ;
201+ dispatchKeyboardEvent ( ul , 'keydown' , DOWN_ARROW ) ;
202+ dispatchKeyboardEvent ( ul , 'keydown' , DOWN_ARROW ) ;
202203 fixture . detectChanges ( ) ;
203204 expect ( oc . nativeElement . querySelector ( '.ant-select-dropdown-menu-item-active' ) . innerText ) . toBe ( 'test2' ) ;
204205 testComponent . searchValue = 'sub1-1' ;
@@ -247,10 +248,10 @@ describe('nz-select option container', () => {
247248 fixture . whenStable ( ) . then ( ( ) => {
248249 expect ( testComponent . nzOptionContainerComponent . listOfTagOption . length ) . toBe ( 1 ) ;
249250 const ul = oc . nativeElement . querySelector ( '.ant-select-dropdown-menu' ) ;
250- dispatchKeyboardEvent ( ul , 'keydown' , 38 ) ;
251- dispatchKeyboardEvent ( ul , 'keydown' , 38 ) ;
251+ dispatchKeyboardEvent ( ul , 'keydown' , UP_ARROW ) ;
252+ dispatchKeyboardEvent ( ul , 'keydown' , UP_ARROW ) ;
252253 fixture . detectChanges ( ) ;
253- dispatchKeyboardEvent ( ul , 'keydown' , 13 ) ;
254+ dispatchKeyboardEvent ( ul , 'keydown' , ENTER ) ;
254255 fixture . detectChanges ( ) ;
255256 expect ( testComponent . nzOptionContainerComponent . listOfTagOption . length ) . toBe ( 1 ) ;
256257 expect ( testComponent . listOfSelectedValue . length ) . toBe ( 3 ) ;
@@ -262,7 +263,7 @@ describe('nz-select option container', () => {
262263 fixture . whenStable ( ) . then ( ( ) => {
263264 expect ( testComponent . nzOptionContainerComponent . listOfTagOption . length ) . toBe ( 1 ) ;
264265 const ul = oc . nativeElement . querySelector ( '.ant-select-dropdown-menu' ) ;
265- dispatchKeyboardEvent ( ul , 'keydown' , 13 ) ;
266+ dispatchKeyboardEvent ( ul , 'keydown' , ENTER ) ;
266267 fixture . detectChanges ( ) ;
267268 expect ( testComponent . nzOptionContainerComponent . listOfTagOption . length ) . toBe ( 2 ) ;
268269 expect ( testComponent . listOfSelectedValue . length ) . toBe ( 3 ) ;
0 commit comments