You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
994 B
42 lines
994 B
5 years ago
|
import React from 'react';
|
||
|
import { mount } from 'enzyme';
|
||
|
import ConfigProvider from '..';
|
||
|
import Affix from '../../affix';
|
||
|
import Anchor from '../../anchor';
|
||
|
|
||
|
describe('ConfigProvider.getTargetContainer', () => {
|
||
|
it('Affix', () => {
|
||
|
jest.useFakeTimers();
|
||
|
const getTargetContainer = jest.fn(() => window);
|
||
|
mount(
|
||
|
<ConfigProvider getTargetContainer={getTargetContainer}>
|
||
|
<Affix>
|
||
|
<span />
|
||
|
</Affix>
|
||
|
</ConfigProvider>,
|
||
|
);
|
||
|
|
||
|
jest.runAllTimers();
|
||
|
|
||
|
expect(getTargetContainer).toHaveBeenCalled();
|
||
|
jest.useRealTimers();
|
||
|
});
|
||
|
|
||
|
it('Anchor', () => {
|
||
|
jest.useFakeTimers();
|
||
|
const getTargetContainer = jest.fn(() => window);
|
||
|
mount(
|
||
|
<ConfigProvider getTargetContainer={getTargetContainer}>
|
||
|
<Anchor>
|
||
|
<Anchor.Link href="#API" title="API" />
|
||
|
</Anchor>
|
||
|
</ConfigProvider>,
|
||
|
);
|
||
|
|
||
|
jest.runAllTimers();
|
||
|
|
||
|
expect(getTargetContainer).toHaveBeenCalled();
|
||
|
jest.useRealTimers();
|
||
|
});
|
||
|
});
|