1- import { ComponentFixture , fakeAsync , flush , TestBed , tick , waitForAsync } from '@angular/core/testing' ;
1+ import { ComponentFixture , fakeAsync , TestBed , tick , waitForAsync } from '@angular/core/testing' ;
22import { FormsModule , ReactiveFormsModule } from '@angular/forms' ;
33import { NoopAnimationsModule } from '@angular/platform-browser/animations' ;
44import { UIInteractions } from '../test-utils/ui-interactions.spec' ;
@@ -132,10 +132,6 @@ describe('IgxDatePicker', () => {
132132 calendar = fixture . componentInstance . datePicker . calendar ;
133133 } ) ) ;
134134
135- afterAll ( ( ) => {
136- TestBed . resetTestingModule ( ) ;
137- } ) ;
138-
139135 it ( 'should toggle the calendar with ALT + DOWN/UP ARROW key' , fakeAsync ( ( ) => {
140136 spyOn ( datePicker . opening , 'emit' ) . and . callThrough ( ) ;
141137 spyOn ( datePicker . opened , 'emit' ) . and . callThrough ( ) ;
@@ -155,12 +151,27 @@ describe('IgxDatePicker', () => {
155151
156152 calendar = document . getElementsByClassName ( CSS_CLASS_CALENDAR ) [ 0 ] ;
157153 UIInteractions . triggerKeyDownEvtUponElem ( 'ArrowUp' , calendar , true , true ) ;
158- tick ( ) ;
154+ tick ( 350 ) ;
159155 fixture . detectChanges ( ) ;
160156 expect ( datePicker . collapsed ) . toBeTruthy ( ) ;
161157 expect ( datePicker . closing . emit ) . toHaveBeenCalledTimes ( 1 ) ;
162158 expect ( datePicker . closed . emit ) . toHaveBeenCalledTimes ( 1 ) ;
163- flush ( ) ;
159+ } ) ) ;
160+
161+ it ( 'should open the calendar with SPACE key' , fakeAsync ( ( ) => {
162+ spyOn ( datePicker . opening , 'emit' ) . and . callThrough ( ) ;
163+ spyOn ( datePicker . opened , 'emit' ) . and . callThrough ( ) ;
164+ expect ( datePicker . collapsed ) . toBeTruthy ( ) ;
165+
166+ const picker = fixture . debugElement . query ( By . css ( CSS_CLASS_DATE_PICKER ) ) ;
167+ UIInteractions . triggerEventHandlerKeyDown ( ' ' , picker ) ;
168+
169+ tick ( 350 ) ;
170+ fixture . detectChanges ( ) ;
171+
172+ expect ( datePicker . collapsed ) . toBeFalsy ( ) ;
173+ expect ( datePicker . opening . emit ) . toHaveBeenCalledTimes ( 1 ) ;
174+ expect ( datePicker . opened . emit ) . toHaveBeenCalledTimes ( 1 ) ;
164175 } ) ) ;
165176
166177 it ( 'should close the calendar with ESC' , fakeAsync ( ( ) => {
@@ -175,12 +186,11 @@ describe('IgxDatePicker', () => {
175186
176187 calendar = document . getElementsByClassName ( CSS_CLASS_CALENDAR ) [ 0 ] ;
177188 UIInteractions . triggerKeyDownEvtUponElem ( 'Escape' , calendar , true ) ;
178- tick ( ) ;
189+ tick ( 350 ) ;
179190 fixture . detectChanges ( ) ;
180191 expect ( datePicker . collapsed ) . toBeTruthy ( ) ;
181192 expect ( datePicker . closing . emit ) . toHaveBeenCalledTimes ( 1 ) ;
182193 expect ( datePicker . closed . emit ) . toHaveBeenCalledTimes ( 1 ) ;
183- flush ( ) ;
184194 } ) ) ;
185195 } ) ;
186196
0 commit comments