Skip to content

Commit

Permalink
Revert "test: replace some slepp with jest.runAllTimers"
Browse files Browse the repository at this point in the history
This reverts commit ad886d1.
  • Loading branch information
zpc7 committed May 7, 2022
1 parent ad886d1 commit bd31a6a
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions components/tooltip/__tests__/tooltip.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@ describe('Tooltip', () => {
spyElementPrototype(HTMLElement, 'offsetParent', {
get: () => ({}),
});
jest.useFakeTimers();
});

afterAll(() => {
jest.useRealTimers();
});

it('check `onVisibleChange` arguments', () => {
Expand Down Expand Up @@ -239,7 +234,6 @@ describe('Tooltip', () => {
});

it('should works for date picker', async () => {
jest.useRealTimers();
const onVisibleChange = jest.fn();
const ref = React.createRef();

Expand All @@ -263,11 +257,9 @@ describe('Tooltip', () => {
expect(onVisibleChange).toHaveBeenCalledWith(false);
expect(ref.current.props.visible).toBe(false);
expect(container.querySelector('.ant-tooltip-open')).toBeNull();
jest.useFakeTimers();
});

it('should works for input group', async () => {
jest.useRealTimers();
const onVisibleChange = jest.fn();
const ref = React.createRef();
const { container } = render(
Expand All @@ -292,7 +284,6 @@ describe('Tooltip', () => {
expect(onVisibleChange).toHaveBeenCalledWith(false);
expect(ref.current.props.visible).toBe(false);
expect(container.querySelector('.ant-tooltip-open')).toBeNull();
jest.useFakeTimers();
});

// https://github.com/ant-design/ant-design/issues/20891
Expand Down Expand Up @@ -355,7 +346,7 @@ describe('Tooltip', () => {
expect(container.getElementsByTagName('span')).toHaveLength(1);
const element = container.getElementsByTagName('span')[0];
fireEvent.mouseEnter(element);
jest.runAllTimers();
await sleep(500);

await waitFor(() => {
expect(document.querySelector(`.ant-tooltip-placement-${placement}`)).not.toBeNull();
Expand All @@ -366,7 +357,7 @@ describe('Tooltip', () => {
placementList.forEach(placement => testPlacement(`Placement ${placement}`, placement));
});

it('should works for mismatch placement', () => {
it('should works for mismatch placement', async () => {
const { container } = render(
<Tooltip
title="xxxxx"
Expand All @@ -380,7 +371,7 @@ describe('Tooltip', () => {
);
const button = container.getElementsByTagName('span')[0];
fireEvent.mouseEnter(button);
jest.runAllTimers();
await sleep(600);
expect(document.querySelector('.ant-tooltip')).not.toBeNull();
});

Expand Down

0 comments on commit bd31a6a

Please sign in to comment.