import { mount } from 'enzyme'; import React from 'react'; import ConfigProvider from '..'; import Affix from '../../affix'; import Anchor from '../../anchor'; import { act } from '../../../tests/utils'; describe('ConfigProvider.getTargetContainer', () => { it('Affix', () => { jest.useFakeTimers(); const getTargetContainer = jest.fn(() => window); mount( , ); act(() => { jest.runAllTimers(); }); expect(getTargetContainer).toHaveBeenCalled(); jest.useRealTimers(); }); it('Anchor', () => { jest.useFakeTimers(); const getTargetContainer = jest.fn(() => window); mount( , ); act(() => { jest.runAllTimers(); }); expect(getTargetContainer).toHaveBeenCalled(); jest.useRealTimers(); }); });