1
- import { IgxLabelDirective } from './../directives/label/label.directive' ;
2
- import { Component , ViewChild , NgModule , ElementRef , EventEmitter , DebugElement } from '@angular/core' ;
1
+ import { Component , ViewChild , DebugElement } from '@angular/core' ;
3
2
import { TestBed , fakeAsync , tick , ComponentFixture , waitForAsync } from '@angular/core/testing' ;
4
- import { FormsModule , FormGroup , FormBuilder , ReactiveFormsModule , Validators } from '@angular/forms' ;
3
+ import { FormsModule } from '@angular/forms' ;
5
4
import { By } from '@angular/platform-browser' ;
6
5
import { NoopAnimationsModule } from '@angular/platform-browser/animations' ;
7
- import { IgxInputDirective , IgxInputState } from '../directives/input/input.directive' ;
8
6
import { IgxTimePickerComponent , IgxTimePickerModule , IgxTimePickerValidationFailedEventArgs } from './time-picker.component' ;
9
- import { UIInteractions , wait } from '../test-utils/ui-interactions.spec' ;
10
- import { IgxInputGroupModule , IgxInputGroupComponent } from '../input-group/public_api' ;
7
+ import { UIInteractions } from '../test-utils/ui-interactions.spec' ;
8
+ import { IgxInputGroupModule } from '../input-group/public_api' ;
11
9
import { configureTestSuite } from '../test-utils/configure-suite' ;
12
10
import { PickerInteractionMode } from '../date-common/types' ;
13
11
import { IgxIconModule } from '../icon/public_api' ;
14
- import { IgxToggleDirective , IgxToggleModule } from '../directives/toggle/toggle.directive' ;
15
- import { IBaseCancelableBrowserEventArgs , IBaseEventArgs , KEYS } from '../core/utils' ;
16
- import { DatePart , IgxDateTimeEditorDirective } from '../directives/date-time-editor/public_api' ;
17
- import { IgxItemListDirective } from './time-picker.directives' ;
12
+ import { IgxToggleDirective } from '../directives/toggle/toggle.directive' ;
13
+ import { KEYS } from '../core/utils' ;
14
+ import { DatePart } from '../directives/date-time-editor/public_api' ;
18
15
import { DateTimeUtil } from '../date-common/util/date-time.util' ;
19
- import { time } from 'console' ;
20
16
21
17
const CSS_CLASS_TIMEPICKER = 'igx-time-picker' ;
22
18
const CSS_CLASS_INPUTGROUP = 'igx-input-group' ;
@@ -25,11 +21,10 @@ const CSS_CLASS_INPUT = '.igx-input-group__input';
25
21
const CSS_CLASS_DROPDOWN = '.igx-time-picker--dropdown' ;
26
22
const CSS_CLASS_HOURLIST = '.igx-time-picker__hourList' ;
27
23
const CSS_CLASS_MINUTELIST = '.igx-time-picker__minuteList' ;
28
- const CSS_CLASS_SECONDSLIST = '.igx-time-picker__secondsList' ;
24
+ // const CSS_CLASS_SECONDSLIST = '.igx-time-picker__secondsList';
29
25
const CSS_CLASS_AMPMLIST = '.igx-time-picker__ampmList' ;
30
26
const CSS_CLASS_SELECTED_ITEM = '.igx-time-picker__item--selected' ;
31
27
const CSS_CLASS_HEADER_HOUR = '.igx-time-picker__header-hour' ;
32
- const CSS_CLASS_HEADER_AMPM = '.igx-time-picker__header-ampm' ;
33
28
const CSS_CLASS_OVERLAY = 'igx-overlay' ;
34
29
const CSS_CLASS_OVERLAY_WRAPPER = 'igx-overlay__wrapper' ;
35
30
@@ -55,7 +50,7 @@ describe('IgxTimePicker', () => {
55
50
timePicker . open ( ) ;
56
51
expect ( mockToggleDirective . open ) . toHaveBeenCalledTimes ( 1 ) ;
57
52
58
- ( Object . getOwnPropertyDescriptor ( mockToggleDirective , " collapsed" ) ?. get as jasmine . Spy < ( ) => boolean > ) . and . returnValue ( false ) ;
53
+ ( Object . getOwnPropertyDescriptor ( mockToggleDirective , ' collapsed' ) ?. get as jasmine . Spy < ( ) => boolean > ) . and . returnValue ( false ) ;
59
54
timePicker . close ( ) ;
60
55
expect ( mockToggleDirective . close ) . toHaveBeenCalledTimes ( 1 ) ;
61
56
} ) ;
@@ -70,7 +65,7 @@ describe('IgxTimePicker', () => {
70
65
timePicker . toggle ( ) ;
71
66
expect ( mockToggleDirective . open ) . toHaveBeenCalledTimes ( 1 ) ;
72
67
73
- ( Object . getOwnPropertyDescriptor ( mockToggleDirective , " collapsed" ) ?. get as jasmine . Spy < ( ) => boolean > ) . and . returnValue ( false ) ;
68
+ ( Object . getOwnPropertyDescriptor ( mockToggleDirective , ' collapsed' ) ?. get as jasmine . Spy < ( ) => boolean > ) . and . returnValue ( false ) ;
74
69
timePicker . toggle ( ) ;
75
70
expect ( mockToggleDirective . close ) . toHaveBeenCalledTimes ( 1 ) ;
76
71
} ) ;
@@ -239,7 +234,7 @@ describe('IgxTimePicker', () => {
239
234
expect ( timePicker . value ) . toEqual ( pickerValue ) ;
240
235
} ) ) ;
241
236
242
- it ( 'should open the dropdown with `ArrowDown` + `Alt` key press and close it and keep the current selection on outside click' , fakeAsync ( ( ) => {
237
+ it ( 'should open the dropdown with `ArrowDown` + `Alt` key press and close it on outside click' , fakeAsync ( ( ) => {
243
238
input . nativeElement . dispatchEvent ( new KeyboardEvent ( 'keydown' , { key : 'ArrowDown' , altKey : true } ) ) ;
244
239
tick ( ) ;
245
240
fixture . detectChanges ( ) ;
@@ -465,7 +460,7 @@ describe('IgxTimePicker', () => {
465
460
fixture = TestBed . createComponent ( IgxTimePickerTestComponent ) ;
466
461
fixture . detectChanges ( ) ;
467
462
timePicker = fixture . componentInstance . timePicker ;
468
- timePickerElement = fixture . debugElement . query ( By . css ( CSS_CLASS_TIMEPICKER ) ) . nativeElement ;
463
+ // timePickerElement = fixture.debugElement.query(By.css(CSS_CLASS_TIMEPICKER)).nativeElement;
469
464
inputGroup = fixture . debugElement . query ( By . css ( `.${ CSS_CLASS_INPUTGROUP } ` ) ) ;
470
465
hourColumn = fixture . debugElement . query ( By . css ( CSS_CLASS_HOURLIST ) ) ;
471
466
minutesColumn = fixture . debugElement . query ( By . css ( CSS_CLASS_MINUTELIST ) ) ;
@@ -562,41 +557,43 @@ describe('IgxTimePicker', () => {
562
557
} ) ) ;
563
558
564
559
it ( 'should apply all aria attributes correctly' , fakeAsync ( ( ) => {
565
- const input = fixture . nativeElement . querySelector ( CSS_CLASS_INPUT ) ;
566
- expect ( input . getAttribute ( 'role' ) ) . toEqual ( 'combobox' ) ;
567
- expect ( input . getAttribute ( 'aria-haspopup' ) ) . toEqual ( 'dialog' ) ;
568
- expect ( input . getAttribute ( 'aria-labelledby' ) ) . toEqual ( timePicker . label . id ) ;
569
- expect ( input . getAttribute ( 'aria-expanded' ) ) . toEqual ( 'false' ) ;
560
+ const inputEl = fixture . nativeElement . querySelector ( CSS_CLASS_INPUT ) ;
561
+ expect ( inputEl . getAttribute ( 'role' ) ) . toEqual ( 'combobox' ) ;
562
+ expect ( inputEl . getAttribute ( 'aria-haspopup' ) ) . toEqual ( 'dialog' ) ;
563
+ expect ( inputEl . getAttribute ( 'aria-labelledby' ) ) . toEqual ( timePicker . label . id ) ;
564
+ expect ( inputEl . getAttribute ( 'aria-expanded' ) ) . toEqual ( 'false' ) ;
565
+
570
566
timePicker . open ( ) ;
571
567
tick ( ) ;
572
568
fixture . detectChanges ( ) ;
573
- expect ( input . getAttribute ( 'aria-expanded' ) ) . toEqual ( 'true' ) ;
569
+ expect ( inputEl . getAttribute ( 'aria-expanded' ) ) . toEqual ( 'true' ) ;
570
+
574
571
let hour = 8 ;
575
572
let minutes = 42 ;
576
573
let ampm = 0 ;
577
- hourColumn . children . forEach ( el => function ( ) {
574
+ hourColumn . children . forEach ( ( el ) => {
578
575
expect ( el . attributes . role ) . toEqual ( 'spinbutton' ) ;
579
576
const hours = hour < 10 ? `0${ hour } ` : `${ hour } ` ;
580
- expect ( el . attributes [ " ariaLabel" ] ) . toEqual ( hours ) ;
577
+ expect ( el . attributes [ ' ariaLabel' ] ) . toEqual ( hours ) ;
581
578
hour ++ ;
582
579
} ) ;
583
- minutesColumn . children . forEach ( el => function ( ) {
580
+ minutesColumn . children . forEach ( ( el ) => {
584
581
expect ( el . attributes . role ) . toEqual ( 'spinbutton' ) ;
585
- expect ( el . attributes [ " ariaLabel" ] ) . toEqual ( `${ minutes } ` ) ;
582
+ expect ( el . attributes [ ' ariaLabel' ] ) . toEqual ( `${ minutes } ` ) ;
586
583
minutes ++ ;
587
584
} ) ;
588
- ampmColumn . children . forEach ( el => function ( ) {
585
+ ampmColumn . children . forEach ( ( el ) => {
589
586
expect ( el . attributes . role ) . toEqual ( 'spinbutton' ) ;
590
587
const ampmLabel = ampm === 3 ? 'AM' : ampm === 4 ? 'PM' : null ;
591
- expect ( el . attributes [ " ariaLabel" ] ) . toEqual ( ampmLabel ) ;
588
+ expect ( el . attributes [ ' ariaLabel' ] ) . toEqual ( ampmLabel ) ;
592
589
ampm ++ ;
593
590
} ) ;
591
+
594
592
timePicker . close ( ) ;
595
- tick ( ) ; [ [ ] ]
593
+ tick ( ) ;
596
594
fixture . detectChanges ( ) ;
597
- expect ( input . getAttribute ( 'aria-expanded' ) ) . toEqual ( 'false' ) ;
595
+ expect ( inputEl . getAttribute ( 'aria-expanded' ) ) . toEqual ( 'false' ) ;
598
596
} ) ) ;
599
-
600
597
} ) ;
601
598
} ) ;
602
599
} ) ;
0 commit comments