mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-12-05 05:28:20 +08:00
7322aa6f5f
This reverts commit 6759887c44
.
46 lines
1.0 KiB
TypeScript
46 lines
1.0 KiB
TypeScript
import React from 'react';
|
|
import ConfigProvider from '..';
|
|
import { act, render } from '../../../tests/utils';
|
|
import Affix from '../../affix';
|
|
import Anchor from '../../anchor';
|
|
|
|
describe('ConfigProvider.getTargetContainer', () => {
|
|
it('Affix', () => {
|
|
jest.useFakeTimers();
|
|
const getTargetContainer = jest.fn(() => window);
|
|
render(
|
|
<ConfigProvider getTargetContainer={getTargetContainer}>
|
|
<Affix>
|
|
<span />
|
|
</Affix>
|
|
</ConfigProvider>,
|
|
);
|
|
|
|
act(() => {
|
|
jest.runAllTimers();
|
|
});
|
|
|
|
expect(getTargetContainer).toHaveBeenCalled();
|
|
jest.useRealTimers();
|
|
});
|
|
|
|
it('Anchor', () => {
|
|
jest.useFakeTimers();
|
|
const getTargetContainer = jest.fn(() => window);
|
|
render(
|
|
<ConfigProvider getTargetContainer={getTargetContainer}>
|
|
<Anchor>
|
|
<Anchor.Link href="#API" title="API" />
|
|
</Anchor>
|
|
</ConfigProvider>,
|
|
);
|
|
|
|
act(() => {
|
|
jest.runAllTimers();
|
|
});
|
|
|
|
expect(getTargetContainer).toHaveBeenCalled();
|
|
jest.useRealTimers();
|
|
});
|
|
});
|