@@ -256,32 +256,49 @@ describe("Table", () => {
256256 } ) ;
257257
258258 it ( "should set the proper aria-sort on an ascending sorted column header" , async ( ) => {
259- const wrapper = render (
260- < Table aria-label = "Static Table" >
261- < TableHeader >
262- < TableColumn allowsSorting data-testid = "test-sort-column" >
263- Foo
264- </ TableColumn >
265- < TableColumn > Bar</ TableColumn >
266- < TableColumn > Baz</ TableColumn >
267- </ TableHeader >
268- < TableBody >
269- < TableRow >
270- < TableCell > Foo 1</ TableCell >
271- < TableCell > Bar 1</ TableCell >
272- < TableCell > Baz 1</ TableCell >
273- </ TableRow >
274- </ TableBody >
275- </ Table > ,
276- ) ;
259+ const TestTable = ( ) => {
260+ const [ sortDescriptor , setSortDescriptor ] = React . useState <
261+ | {
262+ column : React . Key ;
263+ direction : "ascending" | "descending" ;
264+ }
265+ | undefined
266+ > ( undefined ) ;
267+
268+ return (
269+ < Table
270+ aria-label = "Static Table"
271+ sortDescriptor = { sortDescriptor }
272+ onSortChange = { ( descriptor ) => setSortDescriptor ( descriptor ) }
273+ >
274+ < TableHeader >
275+ < TableColumn allowsSorting data-testid = "test-sort-column" >
276+ Foo
277+ </ TableColumn >
278+ < TableColumn > Bar</ TableColumn >
279+ < TableColumn > Baz</ TableColumn >
280+ </ TableHeader >
281+ < TableBody >
282+ < TableRow >
283+ < TableCell > Foo 1</ TableCell >
284+ < TableCell > Bar 1</ TableCell >
285+ < TableCell > Baz 1</ TableCell >
286+ </ TableRow >
287+ </ TableBody >
288+ </ Table >
289+ ) ;
290+ } ;
291+
292+ const wrapper = render ( < TestTable /> ) ;
277293
278294 const column = wrapper . getByTestId ( "test-sort-column" ) ;
279295
280296 expect ( column ) . toHaveAttribute ( "aria-sort" , "none" ) ;
281297
282- act ( async ( ) => {
283- await userEvent . click ( column ) ;
284- expect ( column ) . toHaveAttribute ( "aria-sort" , "ascending" ) ;
298+ await act ( async ( ) => {
299+ await user . click ( column ) ;
285300 } ) ;
301+
302+ expect ( column ) . toHaveAttribute ( "aria-sort" , "ascending" ) ;
286303 } ) ;
287304} ) ;
0 commit comments