11import { describe , it , expect , vi } from "vitest" ;
2- import { render , screen , fireEvent } from "@solidjs/testing-library" ;
2+ import { render , screen } from "@solidjs/testing-library" ;
3+ import userEvent from "@testing-library/user-event" ;
34import ExpandCollapseButtons from "../../src/app/components/shared/ExpandCollapseButtons" ;
45
56describe ( "ExpandCollapseButtons" , ( ) => {
@@ -9,17 +10,19 @@ describe("ExpandCollapseButtons", () => {
910 expect ( screen . getByRole ( "button" , { name : "Collapse all" } ) ) . toBeTruthy ( ) ;
1011 } ) ;
1112
12- it ( "calls onExpandAll when expand button is clicked" , ( ) => {
13+ it ( "calls onExpandAll when expand button is clicked" , async ( ) => {
14+ const user = userEvent . setup ( ) ;
1315 const onExpandAll = vi . fn ( ) ;
1416 render ( ( ) => < ExpandCollapseButtons onExpandAll = { onExpandAll } onCollapseAll = { ( ) => { } } /> ) ;
15- fireEvent . click ( screen . getByRole ( "button" , { name : "Expand all" } ) ) ;
17+ await user . click ( screen . getByRole ( "button" , { name : "Expand all" } ) ) ;
1618 expect ( onExpandAll ) . toHaveBeenCalledTimes ( 1 ) ;
1719 } ) ;
1820
19- it ( "calls onCollapseAll when collapse button is clicked" , ( ) => {
21+ it ( "calls onCollapseAll when collapse button is clicked" , async ( ) => {
22+ const user = userEvent . setup ( ) ;
2023 const onCollapseAll = vi . fn ( ) ;
2124 render ( ( ) => < ExpandCollapseButtons onExpandAll = { ( ) => { } } onCollapseAll = { onCollapseAll } /> ) ;
22- fireEvent . click ( screen . getByRole ( "button" , { name : "Collapse all" } ) ) ;
25+ await user . click ( screen . getByRole ( "button" , { name : "Collapse all" } ) ) ;
2326 expect ( onCollapseAll ) . toHaveBeenCalledTimes ( 1 ) ;
2427 } ) ;
2528} ) ;
0 commit comments