mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-15 17:19:11 +08:00
d689c7b855
* feat: remove locale-provider * chore: fix lint * Empty-Commit * test: remove test * Revert "test: remove test" This reverts commit 4f6b59883f6bf078f21a10898ef913c9e2adb913. * chore: 阶段性兼容 * fix lint * fix: fix lint * fix: add index * docs: update docs * docs: update * docs: update * docs: update
58 lines
1.6 KiB
TypeScript
58 lines
1.6 KiB
TypeScript
import React, { useEffect } from 'react';
|
|
import { Modal } from '../..';
|
|
import { waitFakeTimer, render, fireEvent } from '../../../tests/utils';
|
|
import ConfigProvider from '../../config-provider';
|
|
import zhCN from '../../locale/zh_CN';
|
|
|
|
const Demo: React.FC<{ type: string }> = ({ type }) => {
|
|
useEffect(() => {
|
|
if (type === 'dashboard') {
|
|
Modal.confirm({ title: 'Hello World!' });
|
|
}
|
|
}, []);
|
|
return null;
|
|
};
|
|
|
|
describe('Locale Provider demo', () => {
|
|
it('change type', async () => {
|
|
jest.useFakeTimers();
|
|
|
|
const BasicExample: React.FC = () => {
|
|
const [type, setType] = React.useState<string>('');
|
|
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 { container } = render(<BasicExample />);
|
|
|
|
fireEvent.click(container.querySelector('.about')!);
|
|
await waitFakeTimer();
|
|
|
|
fireEvent.click(container.querySelector('.dashboard')!);
|
|
await waitFakeTimer();
|
|
|
|
expect(document.body.querySelectorAll('.ant-btn-primary span')[0]?.textContent).toBe('确 定');
|
|
Modal.destroyAll();
|
|
jest.useRealTimers();
|
|
});
|
|
});
|