mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-12-15 17:31:25 +08:00
db0344c85f
* test: migrate part of ConfigProvider tests * test: migrate part of ConfigProvider tests * test: update snap * test: update snap * test: migrate part of ConfigProvider tests * fix: commented error case * chore: update snapshot name * test: csp test case * test: revert test case * test: Update snapshot * test: Update ser logic * test: more cov * test: cascader snapshit * test: update match * test: more detact * test: more handler * chore: Update snapshot * test: Table test case Co-authored-by: 二货机器人 <smith3816@gmail.com>
46 lines
1.1 KiB
TypeScript
46 lines
1.1 KiB
TypeScript
import React from 'react';
|
|
import ConfigProvider from '..';
|
|
import Affix from '../../affix';
|
|
import Anchor from '../../anchor';
|
|
import { act, render } from '../../../tests/utils';
|
|
|
|
describe('ConfigProvider.getTargetContainer', () => {
|
|
it('Affix', () => {
|
|
jest.useFakeTimers();
|
|
const getTargetContainer = jest.fn(() => window as unknown as HTMLElement);
|
|
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 as unknown as HTMLElement);
|
|
render(
|
|
<ConfigProvider getTargetContainer={getTargetContainer}>
|
|
<Anchor>
|
|
<Anchor.Link href="#API" title="API" />
|
|
</Anchor>
|
|
</ConfigProvider>,
|
|
);
|
|
|
|
act(() => {
|
|
jest.runAllTimers();
|
|
});
|
|
|
|
expect(getTargetContainer).toHaveBeenCalled();
|
|
jest.useRealTimers();
|
|
});
|
|
});
|