From bd31a6a46aa82b0aaf9df2977e721e6104e41bac Mon Sep 17 00:00:00 2001 From: zpc7 Date: Sat, 7 May 2022 13:05:11 +0800 Subject: [PATCH] Revert "test: replace some slepp with jest.runAllTimers" This reverts commit ad886d1f65d83a92bc9810d6d74c71a3dc1cc608. --- components/tooltip/__tests__/tooltip.test.js | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/components/tooltip/__tests__/tooltip.test.js b/components/tooltip/__tests__/tooltip.test.js index 3d7e759122..67d6a4c08e 100644 --- a/components/tooltip/__tests__/tooltip.test.js +++ b/components/tooltip/__tests__/tooltip.test.js @@ -18,11 +18,6 @@ describe('Tooltip', () => { spyElementPrototype(HTMLElement, 'offsetParent', { get: () => ({}), }); - jest.useFakeTimers(); - }); - - afterAll(() => { - jest.useRealTimers(); }); it('check `onVisibleChange` arguments', () => { @@ -239,7 +234,6 @@ describe('Tooltip', () => { }); it('should works for date picker', async () => { - jest.useRealTimers(); const onVisibleChange = jest.fn(); const ref = React.createRef(); @@ -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( @@ -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 @@ -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(); @@ -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( { ); const button = container.getElementsByTagName('span')[0]; fireEvent.mouseEnter(button); - jest.runAllTimers(); + await sleep(600); expect(document.querySelector('.ant-tooltip')).not.toBeNull(); });