@@ -369,6 +369,7 @@ describe('IgxInput', () => {
369369
370370 const inputGroupElement = fixture . componentInstance . igxInputGroup . element . nativeElement ;
371371 const igxInput = fixture . componentInstance . igxInput ;
372+ const inputElement = igxInput . nativeElement ;
372373 expect ( inputGroupElement . classList . contains ( INPUT_GROUP_INVALID_CSS_CLASS ) ) . toBe ( false ) ;
373374 expect ( igxInput . valid ) . toBe ( IgxInputState . INITIAL ) ;
374375
@@ -380,6 +381,7 @@ describe('IgxInput', () => {
380381
381382 expect ( inputGroupElement . classList . contains ( INPUT_GROUP_INVALID_CSS_CLASS ) ) . toBe ( false ) ;
382383 expect ( igxInput . valid ) . toBe ( IgxInputState . INITIAL ) ;
384+ expect ( inputElement . attributes . getNamedItem ( 'aria-invalid' ) . nodeValue ) . toEqual ( 'false' ) ;
383385
384386 igxInput . value = '' ;
385387 fixture . detectChanges ( ) ;
@@ -388,6 +390,7 @@ describe('IgxInput', () => {
388390
389391 expect ( inputGroupElement . classList . contains ( INPUT_GROUP_INVALID_CSS_CLASS ) ) . toBe ( false ) ;
390392 expect ( igxInput . valid ) . toBe ( IgxInputState . INITIAL ) ;
393+ expect ( inputElement . attributes . getNamedItem ( 'aria-invalid' ) . nodeValue ) . toEqual ( 'false' ) ;
391394
392395 igxInput . value = undefined ;
393396 fixture . detectChanges ( ) ;
@@ -396,6 +399,7 @@ describe('IgxInput', () => {
396399
397400 expect ( inputGroupElement . classList . contains ( INPUT_GROUP_INVALID_CSS_CLASS ) ) . toBe ( false ) ;
398401 expect ( igxInput . valid ) . toBe ( IgxInputState . INITIAL ) ;
402+ expect ( inputElement . attributes . getNamedItem ( 'aria-invalid' ) . nodeValue ) . toEqual ( 'false' ) ;
399403 } ) ) ;
400404
401405 it ( 'should correctly update state of input when value is changed via reactive, no user interactions' , fakeAsync ( ( ) => {
@@ -405,6 +409,7 @@ describe('IgxInput', () => {
405409 const igxInputGroups = fixture . debugElement . queryAll ( By . css ( 'igx-input-group' ) ) ;
406410 const inputGroupElement = igxInputGroups [ 0 ] . nativeElement ;
407411 const igxInput = fixture . componentInstance . strIgxInput ;
412+ const inputElement = igxInput . nativeElement ;
408413
409414 expect ( inputGroupElement . classList . contains ( INPUT_GROUP_INVALID_CSS_CLASS ) ) . toBe ( false ) ;
410415 expect ( igxInput . valid ) . toBe ( IgxInputState . INITIAL ) ;
@@ -414,24 +419,28 @@ describe('IgxInput', () => {
414419
415420 expect ( inputGroupElement . classList . contains ( INPUT_GROUP_INVALID_CSS_CLASS ) ) . toBe ( false ) ;
416421 expect ( igxInput . valid ) . toBe ( IgxInputState . INITIAL ) ;
422+ expect ( inputElement . attributes . getNamedItem ( 'aria-invalid' ) . nodeValue ) . toEqual ( 'false' ) ;
417423
418424 fixture . componentInstance . form . patchValue ( { str : '' } ) ;
419425 fixture . detectChanges ( ) ;
420426
421427 expect ( inputGroupElement . classList . contains ( INPUT_GROUP_INVALID_CSS_CLASS ) ) . toBe ( false ) ;
422428 expect ( igxInput . valid ) . toBe ( IgxInputState . INITIAL ) ;
429+ expect ( inputElement . attributes . getNamedItem ( 'aria-invalid' ) . nodeValue ) . toEqual ( 'false' ) ;
423430
424431 fixture . componentInstance . form . patchValue ( { str : undefined } ) ;
425432 fixture . detectChanges ( ) ;
426433
427434 expect ( inputGroupElement . classList . contains ( INPUT_GROUP_INVALID_CSS_CLASS ) ) . toBe ( false ) ;
428435 expect ( igxInput . valid ) . toBe ( IgxInputState . INITIAL ) ;
436+ expect ( inputElement . attributes . getNamedItem ( 'aria-invalid' ) . nodeValue ) . toEqual ( 'false' ) ;
429437
430438 fixture . componentInstance . form . reset ( ) ;
431439 fixture . detectChanges ( ) ;
432440
433441 expect ( inputGroupElement . classList . contains ( INPUT_GROUP_INVALID_CSS_CLASS ) ) . toBe ( false ) ;
434442 expect ( igxInput . valid ) . toBe ( IgxInputState . INITIAL ) ;
443+ expect ( inputElement . attributes . getNamedItem ( 'aria-invalid' ) . nodeValue ) . toEqual ( 'false' ) ;
435444 } ) ) ;
436445
437446 it ( 'should correctly update state of input when updated through ngModel, with user interactions' , fakeAsync ( ( ) => {
@@ -450,6 +459,7 @@ describe('IgxInput', () => {
450459
451460 expect ( inputGroupElement . classList . contains ( INPUT_GROUP_INVALID_CSS_CLASS ) ) . toBe ( true ) ;
452461 expect ( igxInput . valid ) . toBe ( IgxInputState . INVALID ) ;
462+ expect ( inputElement . attributes . getNamedItem ( 'aria-invalid' ) . nodeValue ) . toEqual ( 'true' ) ;
453463
454464 fixture . componentInstance . user . firstName = 'Bobby' ;
455465
@@ -459,6 +469,7 @@ describe('IgxInput', () => {
459469
460470 expect ( inputGroupElement . classList . contains ( INPUT_GROUP_INVALID_CSS_CLASS ) ) . toBe ( false ) ;
461471 expect ( igxInput . valid ) . toBe ( IgxInputState . INITIAL ) ;
472+ expect ( inputElement . attributes . getNamedItem ( 'aria-invalid' ) . nodeValue ) . toEqual ( 'false' ) ;
462473
463474 fixture . componentInstance . user . firstName = '' ;
464475 fixture . detectChanges ( ) ;
@@ -467,6 +478,7 @@ describe('IgxInput', () => {
467478
468479 expect ( inputGroupElement . classList . contains ( INPUT_GROUP_INVALID_CSS_CLASS ) ) . toBe ( true ) ;
469480 expect ( igxInput . valid ) . toBe ( IgxInputState . INVALID ) ;
481+ expect ( inputElement . attributes . getNamedItem ( 'aria-invalid' ) . nodeValue ) . toEqual ( 'true' ) ;
470482
471483 fixture . componentInstance . user . firstName = undefined ;
472484 fixture . detectChanges ( ) ;
@@ -475,6 +487,7 @@ describe('IgxInput', () => {
475487
476488 expect ( inputGroupElement . classList . contains ( INPUT_GROUP_INVALID_CSS_CLASS ) ) . toBe ( true ) ;
477489 expect ( igxInput . valid ) . toBe ( IgxInputState . INVALID ) ;
490+ expect ( inputElement . attributes . getNamedItem ( 'aria-invalid' ) . nodeValue ) . toEqual ( 'true' ) ;
478491 } ) ) ;
479492
480493 it ( 'should correctly update state of input when value is changed via reactive, with user interactions' , fakeAsync ( ( ) => {
@@ -492,30 +505,35 @@ describe('IgxInput', () => {
492505
493506 expect ( inputGroupElement . classList . contains ( INPUT_GROUP_INVALID_CSS_CLASS ) ) . toBe ( true ) ;
494507 expect ( igxInput . valid ) . toBe ( IgxInputState . INVALID ) ;
508+ expect ( input . attributes . getNamedItem ( 'aria-invalid' ) . nodeValue ) . toEqual ( 'true' ) ;
495509
496510 fixture . componentInstance . form . patchValue ( { str : 'Bobby' } ) ;
497511 fixture . detectChanges ( ) ;
498512
499513 expect ( inputGroupElement . classList . contains ( INPUT_GROUP_INVALID_CSS_CLASS ) ) . toBe ( false ) ;
500514 expect ( igxInput . valid ) . toBe ( IgxInputState . INITIAL ) ;
515+ expect ( input . attributes . getNamedItem ( 'aria-invalid' ) . nodeValue ) . toEqual ( 'false' ) ;
501516
502517 fixture . componentInstance . form . patchValue ( { str : '' } ) ;
503518 fixture . detectChanges ( ) ;
504519
505520 expect ( inputGroupElement . classList . contains ( INPUT_GROUP_INVALID_CSS_CLASS ) ) . toBe ( true ) ;
506521 expect ( igxInput . valid ) . toBe ( IgxInputState . INVALID ) ;
522+ expect ( input . attributes . getNamedItem ( 'aria-invalid' ) . nodeValue ) . toEqual ( 'true' ) ;
507523
508524 fixture . componentInstance . form . patchValue ( { str : undefined } ) ;
509525 fixture . detectChanges ( ) ;
510526
511527 expect ( inputGroupElement . classList . contains ( INPUT_GROUP_INVALID_CSS_CLASS ) ) . toBe ( true ) ;
512528 expect ( igxInput . valid ) . toBe ( IgxInputState . INVALID ) ;
529+ expect ( input . attributes . getNamedItem ( 'aria-invalid' ) . nodeValue ) . toEqual ( 'true' ) ;
513530
514531 fixture . componentInstance . form . reset ( ) ;
515532 fixture . detectChanges ( ) ;
516533
517534 expect ( inputGroupElement . classList . contains ( INPUT_GROUP_INVALID_CSS_CLASS ) ) . toBe ( false ) ;
518535 expect ( igxInput . valid ) . toBe ( IgxInputState . INITIAL ) ;
536+ expect ( input . attributes . getNamedItem ( 'aria-invalid' ) . nodeValue ) . toEqual ( 'false' ) ;
519537 } ) ) ;
520538
521539 it ( 'should correctly update enabled/disabled state of igxInput when changed via reactive form' , fakeAsync ( ( ) => {
@@ -686,6 +704,7 @@ describe('IgxInput', () => {
686704 let asterisk = window . getComputedStyle ( dom . query ( By . css ( '.' + CSS_CLASS_INPUT_GROUP_LABEL ) ) . nativeElement , ':after' ) . content ;
687705 expect ( asterisk ) . toBe ( '"*"' ) ;
688706 expect ( inputGroup . classList . contains ( INPUT_GROUP_REQUIRED_CSS_CLASS ) ) . toBe ( true ) ;
707+ expect ( input . nativeElement . attributes . getNamedItem ( 'aria-required' ) . nodeValue ) . toEqual ( 'true' ) ;
689708
690709 // 2) check that input group's --invalid class is NOT applied
691710 expect ( inputGroup . classList . contains ( INPUT_GROUP_INVALID_CSS_CLASS ) ) . toBe ( false ) ;
@@ -701,6 +720,7 @@ describe('IgxInput', () => {
701720
702721 expect ( inputGroup . classList . contains ( INPUT_GROUP_INVALID_CSS_CLASS ) ) . toBe ( true ) ;
703722 expect ( inputGroup . classList . contains ( INPUT_GROUP_REQUIRED_CSS_CLASS ) ) . toBe ( true ) ;
723+ expect ( input . nativeElement . attributes . getNamedItem ( 'aria-required' ) . nodeValue ) . toEqual ( 'true' ) ;
704724
705725 // 3) Check if the input group's --invalid and --required classes are removed when validator is dynamically cleared
706726 fix . componentInstance . removeValidators ( formGroup ) ;
@@ -713,6 +733,7 @@ describe('IgxInput', () => {
713733 expect ( formReference ) . toBeDefined ( ) ;
714734 expect ( input ) . toBeDefined ( ) ;
715735 expect ( input . nativeElement . value ) . toEqual ( '' ) ;
736+ expect ( input . nativeElement . attributes . getNamedItem ( 'aria-required' ) . nodeValue ) . toEqual ( 'false' ) ;
716737 expect ( inputGroup . classList . contains ( INPUT_GROUP_REQUIRED_CSS_CLASS ) ) . toEqual ( false ) ;
717738 expect ( asterisk ) . toBe ( 'none' ) ;
718739 expect ( input . valid ) . toEqual ( IgxInputState . INITIAL ) ;
@@ -732,6 +753,7 @@ describe('IgxInput', () => {
732753 // interaction test - expect actual asterisk
733754 asterisk = window . getComputedStyle ( dom . query ( By . css ( '.' + CSS_CLASS_INPUT_GROUP_LABEL ) ) . nativeElement , ':after' ) . content ;
734755 expect ( asterisk ) . toBe ( '"*"' ) ;
756+ expect ( input . nativeElement . attributes . getNamedItem ( 'aria-required' ) . nodeValue ) . toEqual ( 'true' ) ;
735757 } ) ) ;
736758} ) ;
737759
0 commit comments