Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
eps1lon committed Oct 5, 2020
1 parent 57f0f10 commit 62246d1
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions packages/material-ui/src/Tooltip/Tooltip.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@ describe('<Tooltip />', () => {
it('should ignore event from the tooltip', () => {
const handleMouseOver = spy();
const { getByRole } = render(
<Tooltip title="Hello World" open interactive>
<Tooltip title="Hello World" open>
<button type="submit" onMouseOver={handleMouseOver}>
Hello World
</button>
Expand Down Expand Up @@ -698,13 +698,12 @@ describe('<Tooltip />', () => {
});
});

describe('prop: interactive', () => {
it('should keep the overlay open if the popper element is hovered', () => {
describe('prop: disableInteractive', () => {
it('when false should keep the overlay open if the popper element is hovered', () => {
const { getByRole } = render(
<Tooltip
title="Hello World"
enterDelay={100}
interactive
leaveDelay={111}
TransitionProps={{ timeout: 10 }}
>
Expand All @@ -731,9 +730,14 @@ describe('<Tooltip />', () => {
expect(getByRole('tooltip')).toBeVisible();
});

it('should not animate twice', () => {
it('when `true` should not keep the overlay open if the popper element is hovered', () => {
const { getByRole } = render(
<Tooltip title="Hello World" interactive enterDelay={500} TransitionProps={{ timeout: 10 }}>
<Tooltip
title="Hello World"
enterDelay={100}
leaveDelay={111}
TransitionProps={{ timeout: 10 }}
>
<button id="testChild" type="submit">
Hello World
</button>
Expand All @@ -742,7 +746,7 @@ describe('<Tooltip />', () => {

fireEvent.mouseOver(getByRole('button'));
act(() => {
clock.tick(500);
clock.tick(100);
});

expect(getByRole('tooltip')).toBeVisible();
Expand All @@ -752,13 +756,9 @@ describe('<Tooltip />', () => {
expect(getByRole('tooltip')).toBeVisible();

fireEvent.mouseOver(getByRole('tooltip'));
clock.tick(10);

expect(getByRole('tooltip')).toBeVisible();
clock.tick(111 + 10);

// TOD: Unclear why not running triggers microtasks but runAll does not trigger microtasks
// can be removed once Popper#update is sync
clock.runAll();
expect(getByRole('tooltip')).not.toBeVisible();
});
});

Expand Down Expand Up @@ -886,7 +886,7 @@ describe('<Tooltip />', () => {
);
});
const { getByRole } = render(
<Tooltip interactive open title="test">
<Tooltip open title="test">
<TextField onFocus={handleFocus} />
</Tooltip>,
);
Expand Down

0 comments on commit 62246d1

Please sign in to comment.