@@ -91,7 +91,7 @@ describe('DateRangePicker', function () {
91
91
expect ( segments [ 0 ] . textContent ) . toBe ( '2' ) ;
92
92
expect ( segments [ 0 ] . getAttribute ( 'aria-label' ) ) . toBe ( 'month' ) ;
93
93
expect ( segments [ 0 ] . getAttribute ( 'aria-valuenow' ) ) . toBe ( '2' ) ;
94
- expect ( segments [ 0 ] . getAttribute ( 'aria-valuetext' ) ) . toBe ( '2 − February' ) ;
94
+ expect ( segments [ 0 ] . getAttribute ( 'aria-valuetext' ) ) . toBe ( '2 – February' ) ;
95
95
expect ( segments [ 0 ] . getAttribute ( 'aria-valuemin' ) ) . toBe ( '1' ) ;
96
96
expect ( segments [ 0 ] . getAttribute ( 'aria-valuemax' ) ) . toBe ( '12' ) ;
97
97
@@ -112,7 +112,7 @@ describe('DateRangePicker', function () {
112
112
expect ( segments [ 3 ] . textContent ) . toBe ( '5' ) ;
113
113
expect ( segments [ 3 ] . getAttribute ( 'aria-label' ) ) . toBe ( 'month' ) ;
114
114
expect ( segments [ 3 ] . getAttribute ( 'aria-valuenow' ) ) . toBe ( '5' ) ;
115
- expect ( segments [ 3 ] . getAttribute ( 'aria-valuetext' ) ) . toBe ( '5 − May' ) ;
115
+ expect ( segments [ 3 ] . getAttribute ( 'aria-valuetext' ) ) . toBe ( '5 – May' ) ;
116
116
expect ( segments [ 3 ] . getAttribute ( 'aria-valuemin' ) ) . toBe ( '1' ) ;
117
117
expect ( segments [ 3 ] . getAttribute ( 'aria-valuemax' ) ) . toBe ( '12' ) ;
118
118
@@ -145,7 +145,7 @@ describe('DateRangePicker', function () {
145
145
expect ( segments [ 0 ] . textContent ) . toBe ( '2' ) ;
146
146
expect ( segments [ 0 ] . getAttribute ( 'aria-label' ) ) . toBe ( 'month' ) ;
147
147
expect ( segments [ 0 ] . getAttribute ( 'aria-valuenow' ) ) . toBe ( '2' ) ;
148
- expect ( segments [ 0 ] . getAttribute ( 'aria-valuetext' ) ) . toBe ( '2 − February' ) ;
148
+ expect ( segments [ 0 ] . getAttribute ( 'aria-valuetext' ) ) . toBe ( '2 – February' ) ;
149
149
expect ( segments [ 0 ] . getAttribute ( 'aria-valuemin' ) ) . toBe ( '1' ) ;
150
150
expect ( segments [ 0 ] . getAttribute ( 'aria-valuemax' ) ) . toBe ( '12' ) ;
151
151
@@ -191,7 +191,7 @@ describe('DateRangePicker', function () {
191
191
expect ( segments [ 7 ] . textContent ) . toBe ( '5' ) ;
192
192
expect ( segments [ 7 ] . getAttribute ( 'aria-label' ) ) . toBe ( 'month' ) ;
193
193
expect ( segments [ 7 ] . getAttribute ( 'aria-valuenow' ) ) . toBe ( '5' ) ;
194
- expect ( segments [ 7 ] . getAttribute ( 'aria-valuetext' ) ) . toBe ( '5 − May' ) ;
194
+ expect ( segments [ 7 ] . getAttribute ( 'aria-valuetext' ) ) . toBe ( '5 – May' ) ;
195
195
expect ( segments [ 7 ] . getAttribute ( 'aria-valuemin' ) ) . toBe ( '1' ) ;
196
196
expect ( segments [ 7 ] . getAttribute ( 'aria-valuemax' ) ) . toBe ( '12' ) ;
197
197
@@ -619,6 +619,20 @@ describe('DateRangePicker', function () {
619
619
620
620
let description = document . getElementById ( group . getAttribute ( 'aria-describedby' ) ) ;
621
621
expect ( description ) . toHaveTextContent ( 'Help text' ) ;
622
+
623
+ let segments = within ( startField ) . getAllByRole ( 'spinbutton' ) ;
624
+ expect ( segments [ 0 ] ) . toHaveAttribute ( 'aria-describedby' , group . getAttribute ( 'aria-describedby' ) ) ;
625
+
626
+ for ( let segment of segments . slice ( 1 ) ) {
627
+ expect ( segment ) . not . toHaveAttribute ( 'aria-describedby' ) ;
628
+ }
629
+
630
+ segments = within ( endField ) . getAllByRole ( 'spinbutton' ) ;
631
+ expect ( segments [ 0 ] ) . toHaveAttribute ( 'aria-describedby' , group . getAttribute ( 'aria-describedby' ) ) ;
632
+
633
+ for ( let segment of segments . slice ( 1 ) ) {
634
+ expect ( segment ) . not . toHaveAttribute ( 'aria-describedby' ) ;
635
+ }
622
636
} ) ;
623
637
624
638
it ( 'should support error message' , function ( ) {
@@ -631,6 +645,11 @@ describe('DateRangePicker', function () {
631
645
632
646
let description = document . getElementById ( group . getAttribute ( 'aria-describedby' ) ) ;
633
647
expect ( description ) . toHaveTextContent ( 'Error message' ) ;
648
+
649
+ let segments = getAllByRole ( 'spinbutton' ) ;
650
+ for ( let segment of segments ) {
651
+ expect ( segment ) . toHaveAttribute ( 'aria-describedby' , group . getAttribute ( 'aria-describedby' ) ) ;
652
+ }
634
653
} ) ;
635
654
636
655
it ( 'should not display error message if not invalid' , function ( ) {
@@ -640,6 +659,11 @@ describe('DateRangePicker', function () {
640
659
expect ( group ) . not . toHaveAttribute ( 'aria-describedby' ) ;
641
660
expect ( startField ) . not . toHaveAttribute ( 'aria-describedby' ) ;
642
661
expect ( endField ) . not . toHaveAttribute ( 'aria-describedby' ) ;
662
+
663
+ let segments = getAllByRole ( 'spinbutton' ) ;
664
+ for ( let segment of segments ) {
665
+ expect ( segment ) . not . toHaveAttribute ( 'aria-describedby' ) ;
666
+ }
643
667
} ) ;
644
668
645
669
it ( 'should support help text with a value' , function ( ) {
@@ -656,8 +680,22 @@ describe('DateRangePicker', function () {
656
680
description = startField . getAttribute ( 'aria-describedby' ) . split ( ' ' ) . map ( d => document . getElementById ( d ) . textContent ) . join ( ' ' ) ;
657
681
expect ( description ) . toBe ( 'February 3, 2020 Help text' ) ;
658
682
683
+ let segments = within ( startField ) . getAllByRole ( 'spinbutton' ) ;
684
+ expect ( segments [ 0 ] ) . toHaveAttribute ( 'aria-describedby' , startField . getAttribute ( 'aria-describedby' ) ) ;
685
+
686
+ for ( let segment of segments . slice ( 1 ) ) {
687
+ expect ( segment ) . not . toHaveAttribute ( 'aria-describedby' ) ;
688
+ }
689
+
659
690
description = endField . getAttribute ( 'aria-describedby' ) . split ( ' ' ) . map ( d => document . getElementById ( d ) . textContent ) . join ( ' ' ) ;
660
691
expect ( description ) . toBe ( 'February 10, 2020 Help text' ) ;
692
+
693
+ segments = within ( endField ) . getAllByRole ( 'spinbutton' ) ;
694
+ expect ( segments [ 0 ] ) . toHaveAttribute ( 'aria-describedby' , endField . getAttribute ( 'aria-describedby' ) ) ;
695
+
696
+ for ( let segment of segments . slice ( 1 ) ) {
697
+ expect ( segment ) . not . toHaveAttribute ( 'aria-describedby' ) ;
698
+ }
661
699
} ) ;
662
700
663
701
it ( 'should support error message with a value' , function ( ) {
@@ -674,8 +712,18 @@ describe('DateRangePicker', function () {
674
712
description = startField . getAttribute ( 'aria-describedby' ) . split ( ' ' ) . map ( d => document . getElementById ( d ) . textContent ) . join ( ' ' ) ;
675
713
expect ( description ) . toBe ( 'February 3, 2020 Error message' ) ;
676
714
715
+ let segments = within ( startField ) . getAllByRole ( 'spinbutton' ) ;
716
+ for ( let segment of segments ) {
717
+ expect ( segment ) . toHaveAttribute ( 'aria-describedby' , startField . getAttribute ( 'aria-describedby' ) ) ;
718
+ }
719
+
677
720
description = endField . getAttribute ( 'aria-describedby' ) . split ( ' ' ) . map ( d => document . getElementById ( d ) . textContent ) . join ( ' ' ) ;
678
721
expect ( description ) . toBe ( 'February 10, 2020 Error message' ) ;
722
+
723
+ segments = within ( endField ) . getAllByRole ( 'spinbutton' ) ;
724
+ for ( let segment of segments ) {
725
+ expect ( segment ) . toHaveAttribute ( 'aria-describedby' , endField . getAttribute ( 'aria-describedby' ) ) ;
726
+ }
679
727
} ) ;
680
728
681
729
it ( 'should support format help text' , function ( ) {
@@ -688,6 +736,11 @@ describe('DateRangePicker', function () {
688
736
expect ( endField ) . not . toHaveAttribute ( 'aria-describedby' ) ;
689
737
690
738
expect ( getByText ( 'month / day / year' ) ) . toBeVisible ( ) ;
739
+
740
+ let segments = getAllByRole ( 'spinbutton' ) ;
741
+ for ( let segment of segments ) {
742
+ expect ( segment ) . not . toHaveAttribute ( 'aria-describedby' ) ;
743
+ }
691
744
} ) ;
692
745
} ) ;
693
746
0 commit comments