@@ -369,6 +369,7 @@ describe('IgxInput', () => {
369
369
370
370
const inputGroupElement = fixture . componentInstance . igxInputGroup . element . nativeElement ;
371
371
const igxInput = fixture . componentInstance . igxInput ;
372
+ const inputElement = igxInput . nativeElement ;
372
373
expect ( inputGroupElement . classList . contains ( INPUT_GROUP_INVALID_CSS_CLASS ) ) . toBe ( false ) ;
373
374
expect ( igxInput . valid ) . toBe ( IgxInputState . INITIAL ) ;
374
375
@@ -380,6 +381,7 @@ describe('IgxInput', () => {
380
381
381
382
expect ( inputGroupElement . classList . contains ( INPUT_GROUP_INVALID_CSS_CLASS ) ) . toBe ( false ) ;
382
383
expect ( igxInput . valid ) . toBe ( IgxInputState . INITIAL ) ;
384
+ expect ( inputElement . attributes . getNamedItem ( 'aria-invalid' ) . nodeValue ) . toEqual ( 'false' ) ;
383
385
384
386
igxInput . value = '' ;
385
387
fixture . detectChanges ( ) ;
@@ -388,6 +390,7 @@ describe('IgxInput', () => {
388
390
389
391
expect ( inputGroupElement . classList . contains ( INPUT_GROUP_INVALID_CSS_CLASS ) ) . toBe ( false ) ;
390
392
expect ( igxInput . valid ) . toBe ( IgxInputState . INITIAL ) ;
393
+ expect ( inputElement . attributes . getNamedItem ( 'aria-invalid' ) . nodeValue ) . toEqual ( 'false' ) ;
391
394
392
395
igxInput . value = undefined ;
393
396
fixture . detectChanges ( ) ;
@@ -396,6 +399,7 @@ describe('IgxInput', () => {
396
399
397
400
expect ( inputGroupElement . classList . contains ( INPUT_GROUP_INVALID_CSS_CLASS ) ) . toBe ( false ) ;
398
401
expect ( igxInput . valid ) . toBe ( IgxInputState . INITIAL ) ;
402
+ expect ( inputElement . attributes . getNamedItem ( 'aria-invalid' ) . nodeValue ) . toEqual ( 'false' ) ;
399
403
} ) ) ;
400
404
401
405
it ( 'should correctly update state of input when value is changed via reactive, no user interactions' , fakeAsync ( ( ) => {
@@ -405,6 +409,7 @@ describe('IgxInput', () => {
405
409
const igxInputGroups = fixture . debugElement . queryAll ( By . css ( 'igx-input-group' ) ) ;
406
410
const inputGroupElement = igxInputGroups [ 0 ] . nativeElement ;
407
411
const igxInput = fixture . componentInstance . strIgxInput ;
412
+ const inputElement = igxInput . nativeElement ;
408
413
409
414
expect ( inputGroupElement . classList . contains ( INPUT_GROUP_INVALID_CSS_CLASS ) ) . toBe ( false ) ;
410
415
expect ( igxInput . valid ) . toBe ( IgxInputState . INITIAL ) ;
@@ -414,24 +419,28 @@ describe('IgxInput', () => {
414
419
415
420
expect ( inputGroupElement . classList . contains ( INPUT_GROUP_INVALID_CSS_CLASS ) ) . toBe ( false ) ;
416
421
expect ( igxInput . valid ) . toBe ( IgxInputState . INITIAL ) ;
422
+ expect ( inputElement . attributes . getNamedItem ( 'aria-invalid' ) . nodeValue ) . toEqual ( 'false' ) ;
417
423
418
424
fixture . componentInstance . form . patchValue ( { str : '' } ) ;
419
425
fixture . detectChanges ( ) ;
420
426
421
427
expect ( inputGroupElement . classList . contains ( INPUT_GROUP_INVALID_CSS_CLASS ) ) . toBe ( false ) ;
422
428
expect ( igxInput . valid ) . toBe ( IgxInputState . INITIAL ) ;
429
+ expect ( inputElement . attributes . getNamedItem ( 'aria-invalid' ) . nodeValue ) . toEqual ( 'false' ) ;
423
430
424
431
fixture . componentInstance . form . patchValue ( { str : undefined } ) ;
425
432
fixture . detectChanges ( ) ;
426
433
427
434
expect ( inputGroupElement . classList . contains ( INPUT_GROUP_INVALID_CSS_CLASS ) ) . toBe ( false ) ;
428
435
expect ( igxInput . valid ) . toBe ( IgxInputState . INITIAL ) ;
436
+ expect ( inputElement . attributes . getNamedItem ( 'aria-invalid' ) . nodeValue ) . toEqual ( 'false' ) ;
429
437
430
438
fixture . componentInstance . form . reset ( ) ;
431
439
fixture . detectChanges ( ) ;
432
440
433
441
expect ( inputGroupElement . classList . contains ( INPUT_GROUP_INVALID_CSS_CLASS ) ) . toBe ( false ) ;
434
442
expect ( igxInput . valid ) . toBe ( IgxInputState . INITIAL ) ;
443
+ expect ( inputElement . attributes . getNamedItem ( 'aria-invalid' ) . nodeValue ) . toEqual ( 'false' ) ;
435
444
} ) ) ;
436
445
437
446
it ( 'should correctly update state of input when updated through ngModel, with user interactions' , fakeAsync ( ( ) => {
@@ -450,6 +459,7 @@ describe('IgxInput', () => {
450
459
451
460
expect ( inputGroupElement . classList . contains ( INPUT_GROUP_INVALID_CSS_CLASS ) ) . toBe ( true ) ;
452
461
expect ( igxInput . valid ) . toBe ( IgxInputState . INVALID ) ;
462
+ expect ( inputElement . attributes . getNamedItem ( 'aria-invalid' ) . nodeValue ) . toEqual ( 'true' ) ;
453
463
454
464
fixture . componentInstance . user . firstName = 'Bobby' ;
455
465
@@ -459,6 +469,7 @@ describe('IgxInput', () => {
459
469
460
470
expect ( inputGroupElement . classList . contains ( INPUT_GROUP_INVALID_CSS_CLASS ) ) . toBe ( false ) ;
461
471
expect ( igxInput . valid ) . toBe ( IgxInputState . INITIAL ) ;
472
+ expect ( inputElement . attributes . getNamedItem ( 'aria-invalid' ) . nodeValue ) . toEqual ( 'false' ) ;
462
473
463
474
fixture . componentInstance . user . firstName = '' ;
464
475
fixture . detectChanges ( ) ;
@@ -467,6 +478,7 @@ describe('IgxInput', () => {
467
478
468
479
expect ( inputGroupElement . classList . contains ( INPUT_GROUP_INVALID_CSS_CLASS ) ) . toBe ( true ) ;
469
480
expect ( igxInput . valid ) . toBe ( IgxInputState . INVALID ) ;
481
+ expect ( inputElement . attributes . getNamedItem ( 'aria-invalid' ) . nodeValue ) . toEqual ( 'true' ) ;
470
482
471
483
fixture . componentInstance . user . firstName = undefined ;
472
484
fixture . detectChanges ( ) ;
@@ -475,6 +487,7 @@ describe('IgxInput', () => {
475
487
476
488
expect ( inputGroupElement . classList . contains ( INPUT_GROUP_INVALID_CSS_CLASS ) ) . toBe ( true ) ;
477
489
expect ( igxInput . valid ) . toBe ( IgxInputState . INVALID ) ;
490
+ expect ( inputElement . attributes . getNamedItem ( 'aria-invalid' ) . nodeValue ) . toEqual ( 'true' ) ;
478
491
} ) ) ;
479
492
480
493
it ( 'should correctly update state of input when value is changed via reactive, with user interactions' , fakeAsync ( ( ) => {
@@ -492,30 +505,35 @@ describe('IgxInput', () => {
492
505
493
506
expect ( inputGroupElement . classList . contains ( INPUT_GROUP_INVALID_CSS_CLASS ) ) . toBe ( true ) ;
494
507
expect ( igxInput . valid ) . toBe ( IgxInputState . INVALID ) ;
508
+ expect ( input . attributes . getNamedItem ( 'aria-invalid' ) . nodeValue ) . toEqual ( 'true' ) ;
495
509
496
510
fixture . componentInstance . form . patchValue ( { str : 'Bobby' } ) ;
497
511
fixture . detectChanges ( ) ;
498
512
499
513
expect ( inputGroupElement . classList . contains ( INPUT_GROUP_INVALID_CSS_CLASS ) ) . toBe ( false ) ;
500
514
expect ( igxInput . valid ) . toBe ( IgxInputState . INITIAL ) ;
515
+ expect ( input . attributes . getNamedItem ( 'aria-invalid' ) . nodeValue ) . toEqual ( 'false' ) ;
501
516
502
517
fixture . componentInstance . form . patchValue ( { str : '' } ) ;
503
518
fixture . detectChanges ( ) ;
504
519
505
520
expect ( inputGroupElement . classList . contains ( INPUT_GROUP_INVALID_CSS_CLASS ) ) . toBe ( true ) ;
506
521
expect ( igxInput . valid ) . toBe ( IgxInputState . INVALID ) ;
522
+ expect ( input . attributes . getNamedItem ( 'aria-invalid' ) . nodeValue ) . toEqual ( 'true' ) ;
507
523
508
524
fixture . componentInstance . form . patchValue ( { str : undefined } ) ;
509
525
fixture . detectChanges ( ) ;
510
526
511
527
expect ( inputGroupElement . classList . contains ( INPUT_GROUP_INVALID_CSS_CLASS ) ) . toBe ( true ) ;
512
528
expect ( igxInput . valid ) . toBe ( IgxInputState . INVALID ) ;
529
+ expect ( input . attributes . getNamedItem ( 'aria-invalid' ) . nodeValue ) . toEqual ( 'true' ) ;
513
530
514
531
fixture . componentInstance . form . reset ( ) ;
515
532
fixture . detectChanges ( ) ;
516
533
517
534
expect ( inputGroupElement . classList . contains ( INPUT_GROUP_INVALID_CSS_CLASS ) ) . toBe ( false ) ;
518
535
expect ( igxInput . valid ) . toBe ( IgxInputState . INITIAL ) ;
536
+ expect ( input . attributes . getNamedItem ( 'aria-invalid' ) . nodeValue ) . toEqual ( 'false' ) ;
519
537
} ) ) ;
520
538
521
539
it ( 'should correctly update enabled/disabled state of igxInput when changed via reactive form' , fakeAsync ( ( ) => {
@@ -686,6 +704,7 @@ describe('IgxInput', () => {
686
704
let asterisk = window . getComputedStyle ( dom . query ( By . css ( '.' + CSS_CLASS_INPUT_GROUP_LABEL ) ) . nativeElement , ':after' ) . content ;
687
705
expect ( asterisk ) . toBe ( '"*"' ) ;
688
706
expect ( inputGroup . classList . contains ( INPUT_GROUP_REQUIRED_CSS_CLASS ) ) . toBe ( true ) ;
707
+ expect ( input . nativeElement . attributes . getNamedItem ( 'aria-required' ) . nodeValue ) . toEqual ( 'true' ) ;
689
708
690
709
// 2) check that input group's --invalid class is NOT applied
691
710
expect ( inputGroup . classList . contains ( INPUT_GROUP_INVALID_CSS_CLASS ) ) . toBe ( false ) ;
@@ -701,6 +720,7 @@ describe('IgxInput', () => {
701
720
702
721
expect ( inputGroup . classList . contains ( INPUT_GROUP_INVALID_CSS_CLASS ) ) . toBe ( true ) ;
703
722
expect ( inputGroup . classList . contains ( INPUT_GROUP_REQUIRED_CSS_CLASS ) ) . toBe ( true ) ;
723
+ expect ( input . nativeElement . attributes . getNamedItem ( 'aria-required' ) . nodeValue ) . toEqual ( 'true' ) ;
704
724
705
725
// 3) Check if the input group's --invalid and --required classes are removed when validator is dynamically cleared
706
726
fix . componentInstance . removeValidators ( formGroup ) ;
@@ -713,6 +733,7 @@ describe('IgxInput', () => {
713
733
expect ( formReference ) . toBeDefined ( ) ;
714
734
expect ( input ) . toBeDefined ( ) ;
715
735
expect ( input . nativeElement . value ) . toEqual ( '' ) ;
736
+ expect ( input . nativeElement . attributes . getNamedItem ( 'aria-required' ) . nodeValue ) . toEqual ( 'false' ) ;
716
737
expect ( inputGroup . classList . contains ( INPUT_GROUP_REQUIRED_CSS_CLASS ) ) . toEqual ( false ) ;
717
738
expect ( asterisk ) . toBe ( 'none' ) ;
718
739
expect ( input . valid ) . toEqual ( IgxInputState . INITIAL ) ;
@@ -732,6 +753,7 @@ describe('IgxInput', () => {
732
753
// interaction test - expect actual asterisk
733
754
asterisk = window . getComputedStyle ( dom . query ( By . css ( '.' + CSS_CLASS_INPUT_GROUP_LABEL ) ) . nativeElement , ':after' ) . content ;
734
755
expect ( asterisk ) . toBe ( '"*"' ) ;
756
+ expect ( input . nativeElement . attributes . getNamedItem ( 'aria-required' ) . nodeValue ) . toEqual ( 'true' ) ;
735
757
} ) ) ;
736
758
} ) ;
737
759
0 commit comments