mirror of
https://github.com/apache/superset.git
synced 2024-09-07 06:17:45 -04:00
test: Fix act errors in FaveStar test (#21360)
This commit is contained in:
parent
ab82b17af3
commit
fd6569e3ed
@ -26,13 +26,13 @@ jest.mock('src/components/Tooltip', () => ({
|
||||
Tooltip: (props: any) => <div data-test="tooltip" {...props} />,
|
||||
}));
|
||||
|
||||
test('render right content', () => {
|
||||
test('render right content', async () => {
|
||||
const props = {
|
||||
itemId: 3,
|
||||
saveFaveStar: jest.fn(),
|
||||
};
|
||||
|
||||
const { rerender } = render(<FaveStar {...props} isStarred />);
|
||||
const { rerender, findByRole } = render(<FaveStar {...props} isStarred />);
|
||||
expect(screen.getByRole('button')).toBeInTheDocument();
|
||||
expect(
|
||||
screen.getByRole('img', { name: 'favorite-selected' }),
|
||||
@ -45,7 +45,7 @@ test('render right content', () => {
|
||||
|
||||
rerender(<FaveStar {...props} />);
|
||||
expect(
|
||||
screen.getByRole('img', { name: 'favorite-unselected' }),
|
||||
await findByRole('img', { name: 'favorite-unselected' }),
|
||||
).toBeInTheDocument();
|
||||
|
||||
expect(props.saveFaveStar).toBeCalledTimes(1);
|
||||
@ -54,7 +54,7 @@ test('render right content', () => {
|
||||
expect(props.saveFaveStar).toBeCalledWith(props.itemId, false);
|
||||
});
|
||||
|
||||
test('render content on tooltip', () => {
|
||||
test('render content on tooltip', async () => {
|
||||
const props = {
|
||||
itemId: 3,
|
||||
showTooltip: true,
|
||||
@ -63,7 +63,7 @@ test('render content on tooltip', () => {
|
||||
|
||||
render(<FaveStar {...props} />);
|
||||
|
||||
expect(screen.getByTestId('tooltip')).toBeInTheDocument();
|
||||
expect(await screen.findByTestId('tooltip')).toBeInTheDocument();
|
||||
expect(screen.getByTestId('tooltip')).toHaveAttribute(
|
||||
'id',
|
||||
'fave-unfave-tooltip',
|
||||
@ -75,7 +75,7 @@ test('render content on tooltip', () => {
|
||||
expect(screen.getByRole('button')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
test('Call fetchFaveStar only on the first render', () => {
|
||||
test('Call fetchFaveStar only on the first render', async () => {
|
||||
const props = {
|
||||
itemId: 3,
|
||||
fetchFaveStar: jest.fn(),
|
||||
@ -84,7 +84,10 @@ test('Call fetchFaveStar only on the first render', () => {
|
||||
showTooltip: false,
|
||||
};
|
||||
|
||||
const { rerender } = render(<FaveStar {...props} />);
|
||||
const { rerender, findByRole } = render(<FaveStar {...props} />);
|
||||
expect(
|
||||
await findByRole('img', { name: 'favorite-unselected' }),
|
||||
).toBeInTheDocument();
|
||||
expect(props.fetchFaveStar).toBeCalledTimes(1);
|
||||
expect(props.fetchFaveStar).toBeCalledWith(props.itemId);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user