@@ -49,9 +49,7 @@ describe('UsaPagination', () => {
49
49
cy . get ( 'li.usa-pagination__item:nth-child(8)' ) . as ( 'item7' )
50
50
cy . get ( 'li.usa-pagination__item:nth-child(9)' ) . as ( 'itemNext' )
51
51
52
- cy . get ( 'nav.usa-pagination' )
53
- . should ( 'have.attr' , 'aria-label' )
54
- . and ( 'contain' , 'Pagination' )
52
+ cy . get ( 'nav.usa-pagination' ) . should ( 'have.attr' , 'aria-label' , 'Pagination' )
55
53
56
54
cy . get ( 'ul.usa-pagination__list li' ) . should ( 'have.length' , 9 )
57
55
@@ -60,31 +58,38 @@ describe('UsaPagination', () => {
60
58
. children ( )
61
59
. should ( 'have.class' , 'usa-pagination__link' )
62
60
. and ( 'have.class' , 'usa-pagination__previous-page' )
63
- . and ( 'have.attr' , 'aria-label' )
64
- . and ( 'contain' , 'Previous page' )
65
- . get ( '@itemPrevious' )
66
- . find ( 'span' )
67
- . should ( 'contain' , 'Previous' )
61
+ . and ( 'have.attr' , 'aria-label' , 'Previous page' )
62
+
63
+ cy . get ( '@itemPrevious' )
64
+ . find ( 'svg' )
65
+ . should ( 'have.class' , 'usa-icon' )
66
+ . and ( 'have.attr' , 'aria-hidden' , 'true' )
67
+ . and ( 'have.attr' , 'role' , 'img' )
68
+
69
+ cy . get ( '@itemPrevious' )
70
+ . find ( 'svg use' )
71
+ . should (
72
+ 'have.attr' ,
73
+ 'xlink:href' ,
74
+ '/assets/img/sprite.svg#navigate_before'
75
+ )
76
+
77
+ cy . get ( '@itemPrevious' ) . find ( 'span' ) . should ( 'contain' , 'Previous' )
68
78
69
79
cy . get ( '@item1' )
70
80
. should ( 'have.class' , 'usa-pagination__page-no' )
71
81
. children ( )
72
82
. should ( 'have.class' , 'usa-pagination__button' )
73
- . and ( 'have.attr' , 'aria-label' )
74
- . and ( 'contain' , 'First page, page 1' )
83
+ . and ( 'have.attr' , 'aria-label' , 'First page, page 1' )
75
84
76
- cy . get ( '@item2' )
77
- . children ( )
78
- . should ( 'have.attr' , 'aria-current' )
79
- . and ( 'contain' , 'page' )
85
+ cy . get ( '@item2' ) . children ( ) . should ( 'have.attr' , 'aria-current' , 'page' )
80
86
81
87
for ( let i = 2 ; i <= 5 ; i ++ ) {
82
88
cy . get ( `@item${ i } ` )
83
89
. should ( 'have.class' , 'usa-pagination__page-no' )
84
90
. children ( )
85
91
. should ( 'have.class' , 'usa-pagination__button' )
86
- . and ( 'have.attr' , 'aria-label' )
87
- . and ( 'contain' , `Page ${ i } ` )
92
+ . and ( 'have.attr' , 'aria-label' , `Page ${ i } ` )
88
93
}
89
94
90
95
cy . get ( '@item6' )
@@ -99,19 +104,26 @@ describe('UsaPagination', () => {
99
104
. should ( 'have.class' , 'usa-pagination__page-no' )
100
105
. children ( )
101
106
. should ( 'have.class' , 'usa-pagination__button' )
102
- . and ( 'have.attr' , 'aria-label' )
103
- . and ( 'contain' , 'Last page, page 8' )
107
+ . and ( 'have.attr' , 'aria-label' , 'Last page, page 8' )
104
108
105
109
cy . get ( '@itemNext' )
106
110
. should ( 'have.class' , 'usa-pagination__arrow' )
107
111
. children ( )
108
112
. should ( 'have.class' , 'usa-pagination__link' )
109
113
. and ( 'have.class' , 'usa-pagination__next-page' )
110
- . and ( 'have.attr' , 'aria-label' )
111
- . and ( 'contain' , 'Next page' )
112
- . get ( '@itemNext' )
113
- . find ( 'span' )
114
- . should ( 'contain' , 'Next' )
114
+ . and ( 'have.attr' , 'aria-label' , 'Next page' )
115
+
116
+ cy . get ( '@itemNext' )
117
+ . find ( 'svg' )
118
+ . should ( 'have.class' , 'usa-icon' )
119
+ . and ( 'have.attr' , 'aria-hidden' , 'true' )
120
+ . and ( 'have.attr' , 'role' , 'img' )
121
+
122
+ cy . get ( '@itemNext' )
123
+ . find ( 'svg use' )
124
+ . should ( 'have.attr' , 'xlink:href' , '/assets/img/sprite.svg#navigate_next' )
125
+
126
+ cy . get ( '@itemNext' ) . find ( 'span' ) . should ( 'contain' , 'Next' )
115
127
} )
116
128
117
129
it ( 'does not show the previous/next links on the first/last pages' , ( ) => {
@@ -199,9 +211,11 @@ describe('UsaPagination', () => {
199
211
} ,
200
212
} )
201
213
202
- cy . get ( 'nav.usa-pagination' )
203
- . should ( 'have.attr' , 'aria-label' )
204
- . and ( 'contain' , 'Test aria label' )
214
+ cy . get ( 'nav.usa-pagination' ) . should (
215
+ 'have.attr' ,
216
+ 'aria-label' ,
217
+ 'Test aria label'
218
+ )
205
219
} )
206
220
207
221
it ( 'shows custom item labels' , ( ) => {
@@ -230,36 +244,29 @@ describe('UsaPagination', () => {
230
244
231
245
cy . get ( '@itemPrevious' )
232
246
. children ( )
233
- . should ( 'have.attr' , 'aria-label' )
234
- . and ( 'contain' , 'TEST Previous page' )
235
- . get ( '@itemPrevious' )
236
- . find ( 'span' )
237
- . should ( 'contain' , 'TEST Previous' )
247
+ . should ( 'have.attr' , 'aria-label' , 'TEST Previous page' )
248
+
249
+ cy . get ( '@itemPrevious' ) . find ( 'span' ) . should ( 'contain' , 'TEST Previous' )
238
250
239
251
cy . get ( '@item1' )
240
252
. children ( )
241
- . should ( 'have.attr' , 'aria-label' )
242
- . and ( 'contain' , 'TEST First page, page 1' )
253
+ . should ( 'have.attr' , 'aria-label' , 'TEST First page, page 1' )
243
254
244
255
for ( let i = 2 ; i <= 5 ; i ++ ) {
245
256
cy . get ( `@item${ i } ` )
246
257
. children ( )
247
- . should ( 'have.attr' , 'aria-label' )
248
- . and ( 'contain' , `TEST Page ${ i } ` )
258
+ . should ( 'have.attr' , 'aria-label' , `TEST Page ${ i } ` )
249
259
}
250
260
251
261
cy . get ( '@item7' )
252
262
. children ( )
253
- . should ( 'have.attr' , 'aria-label' )
254
- . and ( 'contain' , 'TEST Last page, page 10' )
263
+ . should ( 'have.attr' , 'aria-label' , 'TEST Last page, page 10' )
255
264
256
265
cy . get ( '@itemNext' )
257
266
. children ( )
258
- . should ( 'have.attr' , 'aria-label' )
259
- . and ( 'contain' , 'TEST Next page' )
260
- . get ( '@itemNext' )
261
- . find ( 'span' )
262
- . should ( 'contain' , 'TEST Next' )
267
+ . should ( 'have.attr' , 'aria-label' , 'TEST Next page' )
268
+
269
+ cy . get ( '@itemNext' ) . find ( 'span' ) . should ( 'contain' , 'TEST Next' )
263
270
} )
264
271
265
272
it ( 'adds custom CSS classes' , ( ) => {
@@ -616,15 +623,13 @@ describe('UsaPagination', () => {
616
623
. as ( 'itemPrevious' )
617
624
. children ( )
618
625
. should ( 'contain' , 'Test Previous Slot' )
619
- . and ( 'have.attr' , 'aria-label' )
620
- . and ( 'contain' , 'Test aria label' )
626
+ . and ( 'have.attr' , 'aria-label' , 'Test aria label previous' )
621
627
622
628
cy . get ( 'li.usa-pagination__item:nth-last-child(1)' )
623
629
. as ( 'itemNext' )
624
630
. children ( )
625
631
. should ( 'contain' , 'Test Next Slot' )
626
- . and ( 'have.attr' , 'aria-label' )
627
- . and ( 'contain' , 'Test aria label next' )
632
+ . and ( 'have.attr' , 'aria-label' , 'Test aria label next' )
628
633
} )
629
634
630
635
it ( 'clicking next/previous link goes to the next/previous page' , ( ) => {
0 commit comments