Chore: Reduce console output in NavBarItem.test.tsx (#45139)

* Chore: Reduce console ouput in NavBarItem.test.tsx

* Chore: remove async
This commit is contained in:
Hugo Häggmark 2022-02-09 14:07:28 +01:00 committed by GitHub
parent df282a42cb
commit e4534deab3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,5 +1,5 @@
import React from 'react';
import { render, screen, waitFor } from '@testing-library/react';
import { act, render, screen, waitFor } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { BrowserRouter } from 'react-router-dom';
import { locationUtil } from '@grafana/data';
@ -53,8 +53,9 @@ describe('NavBarItem', () => {
it('then the onClick handler should be called', () => {
getTestContext();
userEvent.click(screen.getByRole('button'));
act(() => {
userEvent.click(screen.getByRole('button'));
});
expect(onClickMock).toHaveBeenCalledTimes(1);
});
});
@ -194,7 +195,9 @@ describe('NavBarItem', () => {
expect(screen.getByText('New')).toBeInTheDocument();
});
userEvent.click(screen.getByText('New'));
act(() => {
userEvent.click(screen.getByText('New'));
});
await waitFor(() => {
expect(pushMock).toHaveBeenCalledTimes(1);
expect(pushMock).toHaveBeenCalledWith('/dashboard/new');
@ -218,7 +221,9 @@ describe('NavBarItem', () => {
expect(screen.getByText('New')).toBeInTheDocument();
});
userEvent.click(screen.getByText('New'));
act(() => {
userEvent.click(screen.getByText('New'));
});
await waitFor(() => {
expect(pushMock).toHaveBeenCalledTimes(1);
expect(pushMock).toHaveBeenCalledWith('/grafana/dashboard/new');