@@ -424,6 +424,7 @@ describe('igxSelect', () => {
424
424
expect ( inputElement . nativeElement . getAttribute ( 'aria-haspopup' ) ) . toEqual ( 'listbox' ) ;
425
425
expect ( inputElement . nativeElement . getAttribute ( 'aria-labelledby' ) ) . toEqual ( labelID ) ;
426
426
expect ( dropdownListElement . nativeElement . getAttribute ( 'aria-labelledby' ) ) . toEqual ( labelID ) ;
427
+ expect ( inputElement . nativeElement . getAttribute ( 'aria-required' ) ) . toEqual ( 'false' ) ;
427
428
expect ( inputElement . nativeElement . getAttribute ( 'aria-owns' ) ) . toEqual ( select . listId ) ;
428
429
expect ( inputElement . nativeElement . getAttribute ( 'aria-expanded' ) ) . toEqual ( 'false' ) ;
429
430
expect ( toggleBtn . nativeElement . getAttribute ( 'aria-hidden' ) ) . toEqual ( 'true' ) ;
@@ -574,6 +575,7 @@ describe('igxSelect', () => {
574
575
const dom = fix . debugElement ;
575
576
const selectComp = fix . componentInstance . select ;
576
577
const formGroup : UntypedFormGroup = fix . componentInstance . reactiveForm ;
578
+ inputElement = dom . query ( By . css ( '.' + CSS_CLASS_INPUT ) ) ;
577
579
let inputGroupIsRequiredClass = dom . query ( By . css ( '.' + CSS_CLASS_INPUT_GROUP_REQUIRED ) ) ;
578
580
let inputGroupInvalidClass = dom . query ( By . css ( '.' + CSS_CLASS_INPUT_GROUP_INVALID ) ) ;
579
581
// interaction test - expect actual asterisk
@@ -583,6 +585,7 @@ describe('igxSelect', () => {
583
585
expect ( asterisk ) . toBe ( '"*"' ) ;
584
586
expect ( inputGroupIsRequiredClass ) . toBeDefined ( ) ;
585
587
expect ( inputGroupIsRequiredClass ) . not . toBeNull ( ) ;
588
+ expect ( inputElement . nativeElement . getAttribute ( 'aria-required' ) ) . toEqual ( 'true' ) ;
586
589
587
590
// 2) check that input group's --invalid class is NOT applied
588
591
expect ( inputGroupInvalidClass ) . toBeNull ( ) ;
@@ -604,11 +607,13 @@ describe('igxSelect', () => {
604
607
inputGroupIsRequiredClass = dom . query ( By . css ( '.' + CSS_CLASS_INPUT_GROUP_REQUIRED ) ) ;
605
608
expect ( inputGroupIsRequiredClass ) . not . toBeNull ( ) ;
606
609
expect ( inputGroupIsRequiredClass ) . not . toBeUndefined ( ) ;
610
+ expect ( inputElement . nativeElement . getAttribute ( 'aria-required' ) ) . toEqual ( 'true' ) ;
607
611
608
612
// 3) Check if the input group's --invalid and --required classes are removed when validator is dynamically cleared
609
613
fix . componentInstance . removeValidators ( formGroup ) ;
610
614
fix . detectChanges ( ) ;
611
615
tick ( ) ;
616
+ expect ( inputElement . nativeElement . getAttribute ( 'aria-required' ) ) . toEqual ( 'false' ) ;
612
617
613
618
inputGroupIsRequiredClass = dom . query ( By . css ( '.' + CSS_CLASS_INPUT_GROUP_REQUIRED ) ) ;
614
619
const selectFormReference = fix . componentInstance . reactiveForm . controls . optionsSelect ;
@@ -642,6 +647,7 @@ describe('igxSelect', () => {
642
647
// Re-add all Validators
643
648
fix . componentInstance . addValidators ( formGroup ) ;
644
649
fix . detectChanges ( ) ;
650
+ expect ( inputElement . nativeElement . getAttribute ( 'aria-required' ) ) . toEqual ( 'true' ) ;
645
651
646
652
inputGroupIsRequiredClass = dom . query ( By . css ( '.' + CSS_CLASS_INPUT_GROUP_REQUIRED ) ) ;
647
653
expect ( inputGroupIsRequiredClass ) . toBeDefined ( ) ;
@@ -650,24 +656,6 @@ describe('igxSelect', () => {
650
656
// interaction test - expect actual asterisk
651
657
asterisk = window . getComputedStyle ( dom . query ( By . css ( '.' + CSS_CLASS_INPUT_GROUP_LABEL ) ) . nativeElement , ':after' ) . content ;
652
658
expect ( asterisk ) . toBe ( '"*"' ) ;
653
-
654
- // 4) Should NOT remove asterisk, when remove validators on igxSelect with required HTML attribute set(edge case)
655
- // set required HTML attribute
656
- inputGroup . parent . nativeElement . setAttribute ( 'required' , '' ) ;
657
- // Re-add all Validators
658
- fix . componentInstance . addValidators ( formGroup ) ;
659
- fix . detectChanges ( ) ;
660
- // update and clear validators
661
- fix . componentInstance . removeValidators ( formGroup ) ;
662
- fix . detectChanges ( ) ;
663
- tick ( ) ;
664
- // expect asterisk
665
- asterisk = window . getComputedStyle ( dom . query ( By . css ( '.' + CSS_CLASS_INPUT_GROUP_LABEL ) ) . nativeElement , ':after' ) . content ;
666
- expect ( asterisk ) . toBe ( '"*"' ) ;
667
- inputGroupIsRequiredClass = dom . query ( By . css ( '.' + CSS_CLASS_INPUT_GROUP_REQUIRED ) ) ;
668
- expect ( inputGroupIsRequiredClass ) . toBeDefined ( ) ;
669
- expect ( inputGroupIsRequiredClass ) . not . toBeNull ( ) ;
670
- expect ( inputGroupIsRequiredClass ) . not . toBeUndefined ( ) ;
671
659
} ) ) ;
672
660
673
661
it ( 'should update validity state when programmatically setting errors on reactive form controls' , fakeAsync ( ( ) => {
0 commit comments