mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-12-16 01:41:02 +08:00
a67c0d28d3
* fix: try fix * chore: ci * test: recover * test: more test case * test: more and mote * test: btn test * fix: react 18 compitable * chore: more test * test: all confirm test * chore: tmp * chore: test lib * chore: tmp * chore: tmp * test: back of part * test: back of menu index test * test: more test * test: form test * test: rm IE11 test case * chore: fix compatible * chore: clean up * chore: back of all test case * test: ignore 18 lines * chore: remove render test of enzyme in upload * test: back of IE11 test case to fit 100% coverage * chore: fix pkg deps
71 lines
1.8 KiB
JavaScript
71 lines
1.8 KiB
JavaScript
import React from 'react';
|
|
import { mount } from 'enzyme';
|
|
import { act } from 'react-dom/test-utils';
|
|
import ConfigProvider from '../../config-provider';
|
|
import { Modal } from '../..';
|
|
import { sleep } from '../../../tests/utils';
|
|
import zhCN from '../zh_CN';
|
|
|
|
class Demo extends React.Component {
|
|
static defaultProps = {};
|
|
|
|
componentDidMount() {
|
|
if (this.props.type === 'dashboard') {
|
|
Modal.confirm({ title: 'Hello World!' });
|
|
}
|
|
}
|
|
|
|
render() {
|
|
return <div>{this.props.type}</div>;
|
|
}
|
|
}
|
|
|
|
describe('Locale Provider demo', () => {
|
|
it('change type', async () => {
|
|
jest.useFakeTimers();
|
|
|
|
const BasicExample = () => {
|
|
const [type, setType] = React.useState('');
|
|
return (
|
|
<div>
|
|
<a className="about" onClick={() => setType('about')}>
|
|
about
|
|
</a>
|
|
<a className="dashboard" onClick={() => setType('dashboard')}>
|
|
dashboard
|
|
</a>
|
|
<div>
|
|
{type === 'about' && (
|
|
<ConfigProvider locale={zhCN}>
|
|
<Demo type="about" />
|
|
</ConfigProvider>
|
|
)}
|
|
{type === 'dashboard' && (
|
|
<ConfigProvider locale={zhCN}>
|
|
<Demo type="dashboard" />
|
|
</ConfigProvider>
|
|
)}
|
|
</div>
|
|
</div>
|
|
);
|
|
};
|
|
const wrapper = mount(<BasicExample />);
|
|
|
|
wrapper.find('.about').at(0).simulate('click');
|
|
await act(async () => {
|
|
jest.runAllTimers();
|
|
await sleep();
|
|
});
|
|
|
|
wrapper.find('.dashboard').at(0).simulate('click');
|
|
await act(async () => {
|
|
jest.runAllTimers();
|
|
await sleep();
|
|
});
|
|
|
|
expect(document.body.querySelectorAll('.ant-btn-primary span')[0].textContent).toBe('确 定');
|
|
Modal.destroyAll();
|
|
jest.useRealTimers();
|
|
});
|
|
});
|