Skip to content

Commit

Permalink
Simplify tests
Browse files Browse the repository at this point in the history
  • Loading branch information
joshwooding committed Jul 24, 2020
1 parent e2c6d9c commit b859806
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 70 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,6 @@ describe('<SpeedDialAction />', () => {
});

expect(getByText('placeholder')).to.have.class('bar');

// TODO: Unclear why not running triggers microtasks but runAll does not trigger microtasks
// can be removed once Popper#update is sync
clock.runAll();
});

it('should render a Fab', () => {
Expand Down
15 changes: 5 additions & 10 deletions packages/material-ui/src/Popper/Popper.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ describe('<Popper />', () => {
it('should flip placement when edge is reached', async () => {
const renderSpy = spy();
const popperRef = React.createRef();
const { unmount } = render(
render(
<ThemeProvider theme={rtlTheme}>
<Popper popperRef={popperRef} {...defaultProps} placement="bottom">
{({ placement }) => {
Expand All @@ -118,9 +118,6 @@ describe('<Popper />', () => {
['top'],
['top'],
]);

// FIXME: Unclear why we need this to fix "missing act()"-warning
unmount();
});
});

Expand Down Expand Up @@ -149,12 +146,10 @@ describe('<Popper />', () => {
<Popper {...defaultProps} popperRef={popperRef} placement="top" open />,
);

act(() => {
setProps({
popperOptions: {
placement: 'bottom',
},
});
setProps({
popperOptions: {
placement: 'bottom',
},
});

expect(popperRef.current.state.placement).to.equal('bottom');
Expand Down
56 changes: 0 additions & 56 deletions packages/material-ui/src/Tooltip/Tooltip.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,6 @@ describe('<Tooltip />', () => {
);

expect(getByRole('tooltip')).to.have.class(classes.popper);

// TODO: Unclear why not running triggers microtasks but runAll does not trigger microtasks
// can be removed once Popper#update is sync
clock.runAll();
});

describe('prop: disableHoverListener', () => {
Expand All @@ -109,10 +105,6 @@ describe('<Tooltip />', () => {
);

expect(getByRole('tooltip')).toBeVisible();

// TODO: Unclear why not running triggers microtasks but runAll does not trigger microtasks
// can be removed once Popper#update is sync
clock.runAll();
});

it('should not display if the title is an empty string', () => {
Expand Down Expand Up @@ -229,10 +221,6 @@ describe('<Tooltip />', () => {

expect(handleRequestOpen.callCount).to.equal(1);
expect(handleClose.callCount).to.equal(1);

// TODO: Unclear why not running triggers microtasks but runAll does not trigger microtasks
// can be removed once Popper#update is sync
clock.runAll();
});

describe('touch screen', () => {
Expand Down Expand Up @@ -310,10 +298,6 @@ describe('<Tooltip />', () => {
</button>
</Tooltip>,
);

// TODO: Unclear why not running triggers microtasks but runAll does not trigger microtasks
// can be removed once Popper#update is sync
clock.runAll();
});

it('should handle autoFocus + onFocus forwarding', () => {
Expand All @@ -335,10 +319,6 @@ describe('<Tooltip />', () => {
});

expect(getByRole('tooltip')).toBeVisible();

// TODO: Unclear why not running triggers microtasks but runAll does not trigger microtasks
// can be removed once Popper#update is sync
clock.runAll();
});
});

Expand All @@ -361,10 +341,6 @@ describe('<Tooltip />', () => {
});

expect(getByRole('tooltip')).toBeVisible();

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

it('should use hysteresis with the enterDelay', () => {
Expand Down Expand Up @@ -413,10 +389,6 @@ describe('<Tooltip />', () => {
});

expect(getByRole('tooltip')).toBeVisible();

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

it('should take the leaveDelay into account', () => {
Expand Down Expand Up @@ -499,10 +471,6 @@ describe('<Tooltip />', () => {
fireEvent.mouseOver(getByRole('tooltip'));

expect(handleMouseOver.callCount).to.equal(0);

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

Expand All @@ -517,10 +485,6 @@ describe('<Tooltip />', () => {
</Tooltip>,
);
}).not.toErrorDev();

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

it('should raise a warning when we are uncontrolled and can not listen to events', () => {
Expand All @@ -547,10 +511,6 @@ describe('<Tooltip />', () => {
</Tooltip>,
);
}).not.toErrorDev();

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

Expand Down Expand Up @@ -611,10 +571,6 @@ describe('<Tooltip />', () => {
clock.tick(10);

expect(getByRole('tooltip')).toBeVisible();

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

Expand All @@ -629,10 +585,6 @@ describe('<Tooltip />', () => {
);

expect(getByTestId('popper')).not.to.equal(null);

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

it('should merge popperOptions with arrow modifier', () => {
Expand Down Expand Up @@ -667,10 +619,6 @@ describe('<Tooltip />', () => {
expect(
popperRef.current.state.orderedModifiers.find((x) => x.name === 'arrow').enabled,
).to.equal(true);

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

Expand Down Expand Up @@ -726,10 +674,6 @@ describe('<Tooltip />', () => {
focusVisible(getByRole('button'));

expect(getByRole('tooltip')).toBeVisible();

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

// https://github.com/mui-org/material-ui/issues/19883
Expand Down

0 comments on commit b859806

Please sign in to comment.