@@ -77,17 +77,32 @@ describe('table > sorting', () => {
7777 // Currently sorted as ascending
7878 expect ( $ths . at ( 0 ) . attributes ( 'aria-sort' ) ) . toBe ( 'ascending' )
7979 // For switching to descending
80- expect ( $ths . at ( 0 ) . attributes ( 'aria-label' ) ) . toBe ( wrapper . vm . labelSortDesc )
80+ expect (
81+ $ths
82+ . at ( 0 )
83+ . find ( '.sr-only' )
84+ . text ( )
85+ ) . toContain ( wrapper . vm . labelSortDesc )
8186
8287 // Not sorted by this column
8388 expect ( $ths . at ( 1 ) . attributes ( 'aria-sort' ) ) . toBe ( 'none' )
8489 // For sorting by ascending
85- expect ( $ths . at ( 1 ) . attributes ( 'aria-label' ) ) . toBe ( wrapper . vm . labelSortAsc )
90+ expect (
91+ $ths
92+ . at ( 1 )
93+ . find ( '.sr-only' )
94+ . text ( )
95+ ) . toContain ( wrapper . vm . labelSortAsc )
8696
8797 // Not a sortable column
8898 expect ( $ths . at ( 2 ) . attributes ( 'aria-sort' ) ) . not . toBeDefined ( )
8999 // For clearing sorting
90- expect ( $ths . at ( 2 ) . attributes ( 'aria-label' ) ) . toBe ( wrapper . vm . labelSortClear )
100+ expect (
101+ $ths
102+ . at ( 2 )
103+ . find ( '.sr-only' )
104+ . text ( )
105+ ) . toContain ( wrapper . vm . labelSortClear )
91106
92107 // Change sort direction
93108 wrapper . setProps ( {
@@ -113,17 +128,32 @@ describe('table > sorting', () => {
113128 // Currently sorted as descending
114129 expect ( $ths . at ( 0 ) . attributes ( 'aria-sort' ) ) . toBe ( 'descending' )
115130 // For switching to ascending
116- expect ( $ths . at ( 0 ) . attributes ( 'aria-label' ) ) . toBe ( wrapper . vm . labelSortAsc )
131+ expect (
132+ $ths
133+ . at ( 0 )
134+ . find ( '.sr-only' )
135+ . text ( )
136+ ) . toContain ( wrapper . vm . labelSortAsc )
117137
118138 // Not sorted by this column
119139 expect ( $ths . at ( 1 ) . attributes ( 'aria-sort' ) ) . toBe ( 'none' )
120140 // For sorting by ascending
121- expect ( $ths . at ( 1 ) . attributes ( 'aria-label' ) ) . toBe ( wrapper . vm . labelSortAsc )
141+ expect (
142+ $ths
143+ . at ( 1 )
144+ . find ( '.sr-only' )
145+ . text ( )
146+ ) . toContain ( wrapper . vm . labelSortAsc )
122147
123148 // Not a sortable column
124149 expect ( $ths . at ( 2 ) . attributes ( 'aria-sort' ) ) . not . toBeDefined ( )
125150 // For clearing sorting
126- expect ( $ths . at ( 2 ) . attributes ( 'aria-label' ) ) . toBe ( wrapper . vm . labelSortClear )
151+ expect (
152+ $ths
153+ . at ( 2 )
154+ . find ( '.sr-only' )
155+ . text ( )
156+ ) . toContain ( wrapper . vm . labelSortClear )
127157
128158 // Clear sort
129159 wrapper . setProps ( {
@@ -150,17 +180,32 @@ describe('table > sorting', () => {
150180 // Currently not sorted
151181 expect ( $ths . at ( 0 ) . attributes ( 'aria-sort' ) ) . toBe ( 'none' )
152182 // For sorting by ascending
153- expect ( $ths . at ( 0 ) . attributes ( 'aria-label' ) ) . toBe ( wrapper . vm . labelSortAsc )
183+ expect (
184+ $ths
185+ . at ( 0 )
186+ . find ( '.sr-only' )
187+ . text ( )
188+ ) . toContain ( wrapper . vm . labelSortAsc )
154189
155190 // Not sorted by this column
156191 expect ( $ths . at ( 1 ) . attributes ( 'aria-sort' ) ) . toBe ( 'none' )
157192 // For sorting by ascending
158- expect ( $ths . at ( 1 ) . attributes ( 'aria-label' ) ) . toBe ( wrapper . vm . labelSortAsc )
193+ expect (
194+ $ths
195+ . at ( 1 )
196+ . find ( '.sr-only' )
197+ . text ( )
198+ ) . toContain ( wrapper . vm . labelSortAsc )
159199
160200 // Not a sortable column
161201 expect ( $ths . at ( 2 ) . attributes ( 'aria-sort' ) ) . not . toBeDefined ( )
162202 // For clearing sorting
163- expect ( $ths . at ( 2 ) . attributes ( 'aria-label' ) ) . not . toBeDefined ( )
203+ expect (
204+ $ths
205+ . at ( 2 )
206+ . find ( '.sr-only' )
207+ . exists ( )
208+ ) . toBe ( false )
164209
165210 wrapper . destroy ( )
166211 } )
@@ -351,7 +396,7 @@ describe('table > sorting', () => {
351396 expect ( columnA [ 2 ] ) . toBe ( '2' )
352397 // Should have aria-* labels
353398 expect ( wrapper . findAll ( 'tfoot > tr > th[aria-sort]' ) . length ) . toBe ( 2 )
354- expect ( wrapper . findAll ( 'tfoot > tr > th[aria-label] ' ) . length ) . toBe ( 2 )
399+ expect ( wrapper . findAll ( 'tfoot > tr > th > .sr-only ' ) . length ) . toBe ( 2 )
355400
356401 // Sort by first column
357402 wrapper
@@ -376,7 +421,7 @@ describe('table > sorting', () => {
376421 expect ( columnA [ 2 ] ) . toBe ( '3' )
377422 // Should have aria-* labels
378423 expect ( wrapper . findAll ( 'tfoot > tr > th[aria-sort]' ) . length ) . toBe ( 2 )
379- expect ( wrapper . findAll ( 'tfoot > tr > th[aria-label] ' ) . length ) . toBe ( 3 )
424+ expect ( wrapper . findAll ( 'tfoot > tr > th > .sr-only ' ) . length ) . toBe ( 3 )
380425
381426 // Click first column header again to reverse sort
382427 wrapper
@@ -400,7 +445,7 @@ describe('table > sorting', () => {
400445 expect ( columnA [ 2 ] ) . toBe ( '1' )
401446 // Should have aria-* labels
402447 expect ( wrapper . findAll ( 'tfoot > tr > th[aria-sort]' ) . length ) . toBe ( 2 )
403- expect ( wrapper . findAll ( 'tfoot > tr > th[aria-label] ' ) . length ) . toBe ( 3 )
448+ expect ( wrapper . findAll ( 'tfoot > tr > th > .sr-only ' ) . length ) . toBe ( 3 )
404449
405450 // Click second column header to sort by it (by using keydown.enter)
406451 wrapper
@@ -445,7 +490,7 @@ describe('table > sorting', () => {
445490 expect ( columnA [ 2 ] ) . toBe ( '2' )
446491 // Should have aria-* labels
447492 expect ( wrapper . findAll ( 'tfoot > tr > th[aria-sort]' ) . length ) . toBe ( 2 )
448- expect ( wrapper . findAll ( 'tfoot > tr > th[aria-label] ' ) . length ) . toBe ( 2 )
493+ expect ( wrapper . findAll ( 'tfoot > tr > th > .sr-only ' ) . length ) . toBe ( 2 )
449494
450495 wrapper . destroy ( )
451496 } )
@@ -483,7 +528,7 @@ describe('table > sorting', () => {
483528 expect ( columnA [ 2 ] ) . toBe ( '2' )
484529 // Shouldn't have aria-* labels
485530 expect ( wrapper . findAll ( 'tfoot > tr > th[aria-sort]' ) . length ) . toBe ( 0 )
486- expect ( wrapper . findAll ( 'tfoot > tr > th[aria-label] ' ) . length ) . toBe ( 0 )
531+ expect ( wrapper . findAll ( 'tfoot > tr > th > .sr-only ' ) . length ) . toBe ( 0 )
487532
488533 // Click first column
489534 wrapper
@@ -506,7 +551,7 @@ describe('table > sorting', () => {
506551 expect ( columnA [ 2 ] ) . toBe ( '2' )
507552 // Shouldn't have aria-* labels
508553 expect ( wrapper . findAll ( 'tfoot > tr > th[aria-sort]' ) . length ) . toBe ( 0 )
509- expect ( wrapper . findAll ( 'tfoot > tr > th[aria-label] ' ) . length ) . toBe ( 0 )
554+ expect ( wrapper . findAll ( 'tfoot > tr > th > .sr-only ' ) . length ) . toBe ( 0 )
510555
511556 // Click third column header
512557 wrapper
@@ -529,7 +574,7 @@ describe('table > sorting', () => {
529574 expect ( columnA [ 2 ] ) . toBe ( '2' )
530575 // Shouldn't have aria-* labels
531576 expect ( wrapper . findAll ( 'tfoot > tr > th[aria-sort]' ) . length ) . toBe ( 0 )
532- expect ( wrapper . findAll ( 'tfoot > tr > th[aria-label] ' ) . length ) . toBe ( 0 )
577+ expect ( wrapper . findAll ( 'tfoot > tr > th > .sr-only ' ) . length ) . toBe ( 0 )
533578
534579 wrapper . destroy ( )
535580 } )
@@ -568,17 +613,32 @@ describe('table > sorting', () => {
568613 // Currently not sorted
569614 expect ( $ths . at ( 0 ) . attributes ( 'aria-sort' ) ) . toBe ( 'none' )
570615 // For switching to descending
571- expect ( $ths . at ( 0 ) . attributes ( 'aria-label' ) ) . toBe ( wrapper . vm . labelSortDesc )
616+ expect (
617+ $ths
618+ . at ( 0 )
619+ . find ( '.sr-only' )
620+ . text ( )
621+ ) . toContain ( wrapper . vm . labelSortDesc )
572622
573623 // Not sorted by this column
574624 expect ( $ths . at ( 1 ) . attributes ( 'aria-sort' ) ) . toBe ( 'none' )
575625 // For sorting by ascending
576- expect ( $ths . at ( 1 ) . attributes ( 'aria-label' ) ) . toBe ( wrapper . vm . labelSortDesc )
626+ expect (
627+ $ths
628+ . at ( 1 )
629+ . find ( '.sr-only' )
630+ . text ( )
631+ ) . toContain ( wrapper . vm . labelSortDesc )
577632
578633 // Not a sortable column
579634 expect ( $ths . at ( 2 ) . attributes ( 'aria-sort' ) ) . not . toBeDefined ( )
580635 // For clearing sorting
581- expect ( $ths . at ( 2 ) . attributes ( 'aria-label' ) ) . not . toBeDefined ( )
636+ expect (
637+ $ths
638+ . at ( 2 )
639+ . find ( '.sr-only' )
640+ . exists ( )
641+ ) . toBe ( false )
582642
583643 // Change sort direction (should be descending first)
584644 wrapper
@@ -605,17 +665,32 @@ describe('table > sorting', () => {
605665 // Currently sorted as descending
606666 expect ( $ths . at ( 0 ) . attributes ( 'aria-sort' ) ) . toBe ( 'descending' )
607667 // For switching to ascending
608- expect ( $ths . at ( 0 ) . attributes ( 'aria-label' ) ) . toBe ( wrapper . vm . labelSortAsc )
668+ expect (
669+ $ths
670+ . at ( 0 )
671+ . find ( '.sr-only' )
672+ . text ( )
673+ ) . toContain ( wrapper . vm . labelSortAsc )
609674
610675 // Not sorted by this column
611676 expect ( $ths . at ( 1 ) . attributes ( 'aria-sort' ) ) . toBe ( 'none' )
612677 // For sorting by ascending
613- expect ( $ths . at ( 1 ) . attributes ( 'aria-label' ) ) . toBe ( wrapper . vm . labelSortDesc )
678+ expect (
679+ $ths
680+ . at ( 1 )
681+ . find ( '.sr-only' )
682+ . text ( )
683+ ) . toContain ( wrapper . vm . labelSortDesc )
614684
615685 // Not a sortable column
616686 expect ( $ths . at ( 2 ) . attributes ( 'aria-sort' ) ) . not . toBeDefined ( )
617687 // For clearing sorting
618- expect ( $ths . at ( 2 ) . attributes ( 'aria-label' ) ) . toBe ( wrapper . vm . labelSortClear )
688+ expect (
689+ $ths
690+ . at ( 2 )
691+ . find ( '.sr-only' )
692+ . text ( )
693+ ) . toContain ( wrapper . vm . labelSortClear )
619694
620695 wrapper . destroy ( )
621696 } )
0 commit comments