Skip to content

Commit d287051

Browse files
committed
Use getByRole with name in the click tests
1 parent ecc9db4 commit d287051

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

components/features/bills/CloseDetailButton.test.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ describe('CloseDetailButton', () => {
2626
const user = userEvent.setup();
2727
render(<CloseDetailButton />);
2828

29-
await user.click(screen.getByRole('button'));
29+
await user.click(screen.getByRole('button', { name: /close bill detail/i }));
3030

3131
expect(mockSetSelectedBill).toHaveBeenCalledWith(null);
3232
});
@@ -35,8 +35,9 @@ describe('CloseDetailButton', () => {
3535
const user = userEvent.setup();
3636
render(<CloseDetailButton />);
3737

38-
await user.click(screen.getByRole('button'));
39-
await user.click(screen.getByRole('button'));
38+
const closeButton = screen.getByRole('button', { name: /close bill detail/i });
39+
await user.click(closeButton);
40+
await user.click(closeButton);
4041

4142
expect(mockSetSelectedBill).toHaveBeenCalledTimes(2);
4243
});

0 commit comments

Comments
 (0)