diff --git a/src/Breadcrumb/Breadcrumb.test.jsx b/src/Breadcrumb/Breadcrumb.test.jsx
index 2b8c93b8f8..3b402d971e 100644
--- a/src/Breadcrumb/Breadcrumb.test.jsx
+++ b/src/Breadcrumb/Breadcrumb.test.jsx
@@ -48,7 +48,8 @@ describe('', () => {
expect(screen.getAllByRole('presentation').length).toBe(2);
});
- it('fires the passed in click handler', () => {
+ it('fires the passed in click handler', async () => {
+ const user = userEvent.setup();
const clickHandler = jest.fn();
render();
@@ -56,7 +57,7 @@ describe('', () => {
const links = screen.queryAllByRole('link');
expect(listItems.length).toBe(baseProps.links.length);
- userEvent.click(links[0]);
+ await user.click(links[0]);
expect(clickHandler).toHaveBeenCalled();
});
diff --git a/src/Button/deprecated/Button.test.jsx b/src/Button/deprecated/Button.test.jsx
index cb8fa7cfea..1a34c4dcee 100644
--- a/src/Button/deprecated/Button.test.jsx
+++ b/src/Button/deprecated/Button.test.jsx
@@ -14,21 +14,23 @@ describe('', () => {
expect(button).toBeInTheDocument();
});
- it('puts focus on button on click', () => {
+ it('puts focus on button on click', async () => {
+ const user = userEvent.setup();
const { getByText } = render();
const button = getByText(defaultProps.label);
expect(button).not.toHaveFocus();
- userEvent.click(button);
+ await user.click(button);
expect(button).toHaveFocus();
});
- it('calls onClick prop on click', () => {
+ it('calls onClick prop on click', async () => {
+ const user = userEvent.setup();
const onClickSpy = jest.fn();
const { getByText } = render();
const button = getByText(defaultProps.label);
- userEvent.click(button);
+ await user.click(button);
expect(onClickSpy).toHaveBeenCalledTimes(1);
});
});
diff --git a/src/Card/CardCarousel/tests/CardCarouselControls.test.jsx b/src/Card/CardCarousel/tests/CardCarouselControls.test.jsx
index 0a8c63c66c..a711a9e83b 100644
--- a/src/Card/CardCarousel/tests/CardCarouselControls.test.jsx
+++ b/src/Card/CardCarousel/tests/CardCarouselControls.test.jsx
@@ -88,7 +88,8 @@ describe('', () => {
expect(tree).toMatchSnapshot();
});
- it('handles scroll to previous click', () => {
+ it('handles scroll to previous click', async () => {
+ const user = userEvent.setup();
const contextValue = {
...defaultCardCarouselContextValue,
isScrolledToStart: false,
@@ -96,11 +97,12 @@ describe('', () => {
render((
));
- userEvent.click(screen.getByLabelText('Scroll to previous'));
+ await user.click(screen.getByLabelText('Scroll to previous'));
expect(mockScrollToPrevious).toHaveBeenCalledTimes(1);
});
- it('handles scroll to next click', () => {
+ it('handles scroll to next click', async () => {
+ const user = userEvent.setup();
const contextValue = {
...defaultCardCarouselContextValue,
isScrolledToEnd: false,
@@ -108,7 +110,7 @@ describe('', () => {
render((
));
- userEvent.click(screen.getByLabelText('Scroll to next'));
+ await user.click(screen.getByLabelText('Scroll to next'));
expect(mockScrollToNext).toHaveBeenCalledTimes(1);
});
});