@@ -282,7 +282,10 @@ describe('Table', () => {
282
282
} ) ;
283
283
expect ( screen . getAllByRole ( 'row' ) . length ) . toEqual ( data . length + 1 ) ;
284
284
const th = screen . getByRole ( 'columnheader' , { name : 'Text' } ) ;
285
+ const sortingElement = screen . getByText ( 'Text' ) ;
286
+
285
287
expect ( th ) . toBeInTheDocument ( ) ;
288
+ expect ( sortingElement ) . toBeInTheDocument ( ) ;
286
289
287
290
let rows = screen . getAllByRole ( 'row' ) ;
288
291
// Check initial sort order by text column is descending
@@ -293,15 +296,15 @@ describe('Table', () => {
293
296
expect ( rows [ 1 ] . textContent ?. indexOf ( 'sit' ) ) . toBeGreaterThan ( - 1 ) ;
294
297
295
298
// Disable sorting by text column
296
- await userEvent . click ( th ) ;
299
+ await userEvent . click ( sortingElement ) ;
297
300
rows = screen . getAllByRole ( 'row' ) ;
298
301
expect ( rows [ 1 ] . textContent ?. indexOf ( 'lorem' ) ) . toBeGreaterThan ( - 1 ) ;
299
302
expect ( rows [ 2 ] . textContent ?. indexOf ( 'ipsum' ) ) . toBeGreaterThan ( - 1 ) ;
300
303
expect ( rows [ 3 ] . textContent ?. indexOf ( 'dolor' ) ) . toBeGreaterThan ( - 1 ) ;
301
304
expect ( rows [ 4 ] . textContent ?. indexOf ( 'sit' ) ) . toBeGreaterThan ( - 1 ) ;
302
305
303
306
// Sort by text column ascending
304
- await userEvent . click ( th ) ;
307
+ await userEvent . click ( sortingElement ) ;
305
308
rows = screen . getAllByRole ( 'row' ) ;
306
309
expect ( rows [ 1 ] . textContent ?. indexOf ( 'dolor' ) ) . toBeGreaterThan ( - 1 ) ;
307
310
expect ( rows [ 2 ] . textContent ?. indexOf ( 'ipsum' ) ) . toBeGreaterThan ( - 1 ) ;
0 commit comments