Skip to content

Commit

Permalink
3 act errors removed from FaveStar test
Browse files Browse the repository at this point in the history
  • Loading branch information
lyndsiWilliams committed Sep 7, 2022
1 parent ce3d38d commit bb4f437
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions superset-frontend/src/components/FaveStar/FaveStar.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ jest.mock('src/components/Tooltip', () => ({
Tooltip: (props: any) => <div data-test="tooltip" {...props} />,
}));

test('render right content', () => {
it('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' }),
Expand All @@ -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);
Expand All @@ -54,7 +54,7 @@ test('render right content', () => {
expect(props.saveFaveStar).toBeCalledWith(props.itemId, false);
});

test('render content on tooltip', () => {
it('render content on tooltip', async () => {
const props = {
itemId: 3,
showTooltip: true,
Expand All @@ -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',
Expand All @@ -75,7 +75,7 @@ test('render content on tooltip', () => {
expect(screen.getByRole('button')).toBeInTheDocument();
});

test('Call fetchFaveStar only on the first render', () => {
it('Call fetchFaveStar only on the first render', async () => {
const props = {
itemId: 3,
fetchFaveStar: jest.fn(),
Expand All @@ -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);

Expand Down

0 comments on commit bb4f437

Please sign in to comment.