2018-06-19 16:47:52 +08:00
|
|
|
import React from 'react';
|
2024-02-28 15:28:25 +08:00
|
|
|
|
2022-09-05 19:41:32 +08:00
|
|
|
import type { DrawerProps } from '..';
|
2018-06-19 16:47:52 +08:00
|
|
|
import Drawer from '..';
|
2024-02-28 15:28:25 +08:00
|
|
|
import { resetWarned } from '../../_util/warning';
|
2019-08-26 22:53:20 +08:00
|
|
|
import mountTest from '../../../tests/shared/mountTest';
|
2020-01-02 19:10:16 +08:00
|
|
|
import rtlTest from '../../../tests/shared/rtlTest';
|
2024-04-28 09:52:54 +08:00
|
|
|
import { act, fireEvent, render } from '../../../tests/utils';
|
2023-06-07 11:54:50 +08:00
|
|
|
import ConfigProvider from '../../config-provider';
|
2018-06-19 16:47:52 +08:00
|
|
|
|
2022-09-05 19:41:32 +08:00
|
|
|
const DrawerTest: React.FC<DrawerProps> = ({ getContainer }) => (
|
2020-12-09 17:12:32 +08:00
|
|
|
<div>
|
2022-08-23 16:22:00 +08:00
|
|
|
<Drawer open width={400} getContainer={getContainer}>
|
2020-12-09 17:12:32 +08:00
|
|
|
Here is content of Drawer
|
|
|
|
</Drawer>
|
|
|
|
</div>
|
|
|
|
);
|
2020-06-07 19:05:44 +08:00
|
|
|
|
2018-06-19 16:47:52 +08:00
|
|
|
describe('Drawer', () => {
|
2019-08-26 22:53:20 +08:00
|
|
|
mountTest(Drawer);
|
2020-01-02 19:10:16 +08:00
|
|
|
rtlTest(Drawer);
|
2019-08-26 22:53:20 +08:00
|
|
|
|
2022-07-25 21:04:43 +08:00
|
|
|
beforeEach(() => {
|
2023-06-07 21:59:21 +08:00
|
|
|
jest.useFakeTimers();
|
2022-07-25 21:04:43 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(() => {
|
2023-06-07 21:59:21 +08:00
|
|
|
jest.useRealTimers();
|
2022-07-25 21:04:43 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
function triggerMotion() {
|
|
|
|
act(() => {
|
2023-06-07 21:59:21 +08:00
|
|
|
jest.runAllTimers();
|
2022-07-25 21:04:43 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
const mask = document.querySelector('.ant-drawer-mask');
|
|
|
|
if (mask) {
|
|
|
|
fireEvent.animationEnd(mask);
|
|
|
|
}
|
|
|
|
|
|
|
|
const panel = document.querySelector('.ant-drawer-content');
|
|
|
|
if (panel) {
|
|
|
|
fireEvent.animationEnd(panel);
|
|
|
|
}
|
|
|
|
|
|
|
|
act(() => {
|
2023-06-07 21:59:21 +08:00
|
|
|
jest.runAllTimers();
|
2022-07-25 21:04:43 +08:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2018-07-20 14:40:03 +08:00
|
|
|
it('render correctly', () => {
|
2022-06-01 09:40:25 +08:00
|
|
|
const { container: wrapper } = render(
|
2022-08-23 16:22:00 +08:00
|
|
|
<Drawer open width={400} getContainer={false}>
|
2018-07-20 14:40:03 +08:00
|
|
|
Here is content of Drawer
|
2018-12-07 16:17:45 +08:00
|
|
|
</Drawer>,
|
2018-07-20 14:40:03 +08:00
|
|
|
);
|
2022-07-25 21:04:43 +08:00
|
|
|
|
|
|
|
triggerMotion();
|
|
|
|
|
2022-06-01 09:40:25 +08:00
|
|
|
expect(wrapper.firstChild).toMatchSnapshot();
|
2018-07-20 14:40:03 +08:00
|
|
|
});
|
|
|
|
|
2020-06-07 19:05:44 +08:00
|
|
|
it('getContainer return undefined', () => {
|
2022-09-05 19:41:32 +08:00
|
|
|
const { container, rerender } = render(
|
|
|
|
<DrawerTest getContainer={() => undefined as unknown as HTMLElement} />,
|
|
|
|
);
|
2022-07-25 21:04:43 +08:00
|
|
|
triggerMotion();
|
2022-09-05 19:41:32 +08:00
|
|
|
expect(container.firstChild).toMatchSnapshot();
|
2022-07-25 21:04:43 +08:00
|
|
|
|
2022-06-01 09:40:25 +08:00
|
|
|
rerender(<DrawerTest getContainer={false} />);
|
2022-07-25 21:04:43 +08:00
|
|
|
triggerMotion();
|
2022-09-05 19:41:32 +08:00
|
|
|
expect(container.firstChild).toMatchSnapshot();
|
2020-06-07 19:05:44 +08:00
|
|
|
});
|
|
|
|
|
2018-08-10 13:32:33 +08:00
|
|
|
it('render top drawer', () => {
|
2022-09-05 19:41:32 +08:00
|
|
|
const { container } = render(
|
2022-09-05 22:02:23 +08:00
|
|
|
<Drawer open height={400} placement="top" getContainer={false}>
|
2018-08-10 13:32:33 +08:00
|
|
|
Here is content of Drawer
|
2018-12-07 16:17:45 +08:00
|
|
|
</Drawer>,
|
2018-08-10 13:32:33 +08:00
|
|
|
);
|
2022-07-25 21:04:43 +08:00
|
|
|
|
|
|
|
triggerMotion();
|
2022-09-05 19:41:32 +08:00
|
|
|
expect(container.firstChild).toMatchSnapshot();
|
2018-08-10 13:32:33 +08:00
|
|
|
});
|
|
|
|
|
2018-07-20 14:40:03 +08:00
|
|
|
it('have a title', () => {
|
2022-09-05 19:41:32 +08:00
|
|
|
const { container } = render(
|
2022-08-23 16:22:00 +08:00
|
|
|
<Drawer open title="Test Title" getContainer={false}>
|
2018-07-20 14:40:03 +08:00
|
|
|
Here is content of Drawer
|
2018-12-07 16:17:45 +08:00
|
|
|
</Drawer>,
|
2018-07-20 14:40:03 +08:00
|
|
|
);
|
2022-07-25 21:04:43 +08:00
|
|
|
|
|
|
|
triggerMotion();
|
2022-09-05 19:41:32 +08:00
|
|
|
expect(container.firstChild).toMatchSnapshot();
|
2018-07-20 14:40:03 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
it('closable is false', () => {
|
2022-06-01 09:40:25 +08:00
|
|
|
const { container: wrapper } = render(
|
2022-08-23 16:22:00 +08:00
|
|
|
<Drawer open closable={false} getContainer={false}>
|
2018-07-20 14:40:03 +08:00
|
|
|
Here is content of Drawer
|
2018-12-07 16:17:45 +08:00
|
|
|
</Drawer>,
|
2018-07-20 14:40:03 +08:00
|
|
|
);
|
2022-07-25 21:04:43 +08:00
|
|
|
|
|
|
|
triggerMotion();
|
2022-06-01 09:40:25 +08:00
|
|
|
expect(wrapper.firstChild).toMatchSnapshot();
|
2018-07-20 14:40:03 +08:00
|
|
|
});
|
|
|
|
|
2018-06-21 12:32:13 +08:00
|
|
|
it('destroyOnClose is true', () => {
|
2022-06-01 09:40:25 +08:00
|
|
|
const { container: wrapper } = render(
|
2022-08-23 16:22:00 +08:00
|
|
|
<Drawer destroyOnClose open={false} getContainer={false}>
|
2018-06-26 11:19:49 +08:00
|
|
|
Here is content of Drawer
|
2018-12-07 16:17:45 +08:00
|
|
|
</Drawer>,
|
2018-06-26 11:19:49 +08:00
|
|
|
);
|
2022-07-25 21:04:43 +08:00
|
|
|
|
|
|
|
triggerMotion();
|
2022-06-01 09:40:25 +08:00
|
|
|
expect(wrapper.firstChild).toMatchSnapshot();
|
2018-06-19 16:47:52 +08:00
|
|
|
});
|
2018-07-22 11:27:48 +08:00
|
|
|
|
2018-08-05 14:16:08 +08:00
|
|
|
it('className is test_drawer', () => {
|
2022-06-01 09:40:25 +08:00
|
|
|
const { container: wrapper } = render(
|
2022-08-23 16:22:00 +08:00
|
|
|
<Drawer destroyOnClose open rootClassName="test_drawer" getContainer={false}>
|
2018-07-22 11:27:48 +08:00
|
|
|
Here is content of Drawer
|
2018-12-07 16:17:45 +08:00
|
|
|
</Drawer>,
|
2018-07-22 11:27:48 +08:00
|
|
|
);
|
2022-07-25 21:04:43 +08:00
|
|
|
|
|
|
|
triggerMotion();
|
2022-06-01 09:40:25 +08:00
|
|
|
expect(wrapper.firstChild).toMatchSnapshot();
|
2018-07-22 11:27:48 +08:00
|
|
|
});
|
2019-10-07 18:58:10 +08:00
|
|
|
|
|
|
|
it('style/drawerStyle/headerStyle/bodyStyle should work', () => {
|
2023-08-01 01:26:41 +08:00
|
|
|
const style: React.CSSProperties = {
|
2019-10-07 18:58:10 +08:00
|
|
|
backgroundColor: '#08c',
|
|
|
|
};
|
2022-06-01 09:40:25 +08:00
|
|
|
const { container: wrapper } = render(
|
2019-10-07 18:58:10 +08:00
|
|
|
<Drawer
|
2022-08-23 16:22:00 +08:00
|
|
|
open
|
2022-08-01 23:20:04 +08:00
|
|
|
rootStyle={style}
|
2019-10-07 18:58:10 +08:00
|
|
|
drawerStyle={style}
|
|
|
|
headerStyle={style}
|
|
|
|
bodyStyle={style}
|
|
|
|
getContainer={false}
|
|
|
|
>
|
|
|
|
Here is content of Drawer
|
|
|
|
</Drawer>,
|
|
|
|
);
|
2022-07-25 21:04:43 +08:00
|
|
|
|
|
|
|
triggerMotion();
|
2022-06-01 09:40:25 +08:00
|
|
|
expect(wrapper.firstChild).toMatchSnapshot();
|
2019-10-07 18:58:10 +08:00
|
|
|
});
|
2020-01-06 14:56:00 +08:00
|
|
|
|
|
|
|
it('have a footer', () => {
|
2022-06-01 09:40:25 +08:00
|
|
|
const { container: wrapper } = render(
|
2022-08-23 16:22:00 +08:00
|
|
|
<Drawer open footer="Test Footer" getContainer={false}>
|
2020-01-06 14:56:00 +08:00
|
|
|
Here is content of Drawer
|
|
|
|
</Drawer>,
|
|
|
|
);
|
2022-07-25 21:04:43 +08:00
|
|
|
|
|
|
|
triggerMotion();
|
2022-06-01 09:40:25 +08:00
|
|
|
expect(wrapper.firstChild).toMatchSnapshot();
|
2020-01-06 14:56:00 +08:00
|
|
|
});
|
2020-03-02 17:28:45 +08:00
|
|
|
|
|
|
|
it('forceRender works', () => {
|
2022-06-01 09:40:25 +08:00
|
|
|
const { baseElement, rerender } = render(
|
2020-03-02 17:28:45 +08:00
|
|
|
<Drawer>
|
2020-06-07 19:05:44 +08:00
|
|
|
<button type="button" className="forceRender">
|
|
|
|
should not be rendered
|
|
|
|
</button>
|
2020-03-02 17:28:45 +08:00
|
|
|
</Drawer>,
|
|
|
|
);
|
2022-06-01 09:40:25 +08:00
|
|
|
expect(baseElement.querySelectorAll('button.forceRender').length).toBe(0);
|
|
|
|
rerender(
|
2020-03-02 17:28:45 +08:00
|
|
|
<Drawer forceRender>
|
2020-06-07 19:05:44 +08:00
|
|
|
<button type="button" className="forceRender">
|
|
|
|
should be rendered
|
|
|
|
</button>
|
2020-03-02 17:28:45 +08:00
|
|
|
</Drawer>,
|
|
|
|
);
|
2022-06-01 09:40:25 +08:00
|
|
|
expect(baseElement.querySelectorAll('button.forceRender').length).toBe(1);
|
2020-06-07 19:05:44 +08:00
|
|
|
});
|
2020-06-28 22:41:59 +08:00
|
|
|
|
2024-04-29 09:57:45 +08:00
|
|
|
describe('Drawer loading', () => {
|
|
|
|
it('have a spinner', () => {
|
|
|
|
const { container: wrapper } = render(
|
|
|
|
<Drawer open loading getContainer={false}>
|
|
|
|
Here is content of Drawer
|
|
|
|
</Drawer>,
|
|
|
|
);
|
|
|
|
|
|
|
|
triggerMotion();
|
|
|
|
expect(wrapper.firstChild).toMatchSnapshot();
|
|
|
|
});
|
|
|
|
it('have a custom loading', () => {
|
2024-05-14 14:15:33 +08:00
|
|
|
const { container } = render(
|
|
|
|
<Drawer open loading getContainer={false}>
|
2024-04-29 09:57:45 +08:00
|
|
|
Here is content of Drawer
|
|
|
|
</Drawer>,
|
|
|
|
);
|
|
|
|
triggerMotion();
|
2024-05-14 14:15:33 +08:00
|
|
|
const wrapper = container.querySelector<HTMLDivElement>('.ant-skeleton');
|
|
|
|
expect(wrapper).toBeTruthy();
|
2024-04-29 09:57:45 +08:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2020-06-28 22:41:59 +08:00
|
|
|
it('support closeIcon', () => {
|
2022-06-01 09:40:25 +08:00
|
|
|
const { container: wrapper } = render(
|
2022-08-23 16:22:00 +08:00
|
|
|
<Drawer open closable closeIcon={<span>close</span>} width={400} getContainer={false}>
|
2020-06-28 22:41:59 +08:00
|
|
|
Here is content of Drawer
|
|
|
|
</Drawer>,
|
|
|
|
);
|
2022-07-25 21:04:43 +08:00
|
|
|
|
|
|
|
triggerMotion();
|
2022-06-01 09:40:25 +08:00
|
|
|
expect(wrapper.firstChild).toMatchSnapshot();
|
2020-06-28 22:41:59 +08:00
|
|
|
});
|
2020-10-24 14:47:44 +08:00
|
|
|
|
|
|
|
it('ConfigProvider should not warning', () => {
|
2023-06-07 21:59:21 +08:00
|
|
|
const errorSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
|
2020-10-24 14:47:44 +08:00
|
|
|
|
2022-04-06 11:07:15 +08:00
|
|
|
render(
|
2020-10-24 14:47:44 +08:00
|
|
|
<ConfigProvider virtual>
|
2022-08-23 16:22:00 +08:00
|
|
|
<Drawer open>Bamboo is Light</Drawer>
|
2020-10-24 14:47:44 +08:00
|
|
|
</ConfigProvider>,
|
|
|
|
);
|
|
|
|
|
|
|
|
expect(errorSpy).not.toHaveBeenCalled();
|
|
|
|
|
|
|
|
errorSpy.mockRestore();
|
|
|
|
});
|
2022-08-08 22:09:51 +08:00
|
|
|
|
|
|
|
it('zIndex should work', () => {
|
2022-08-23 14:52:37 +08:00
|
|
|
const { container } = render(<Drawer getContainer={false} open zIndex={903} />);
|
2022-08-09 14:31:53 +08:00
|
|
|
expect(container.querySelector('.ant-drawer')).toHaveStyle({
|
2022-08-08 22:09:51 +08:00
|
|
|
zIndex: 903,
|
|
|
|
});
|
|
|
|
});
|
2022-12-02 22:44:16 +08:00
|
|
|
|
|
|
|
describe('style migrate', () => {
|
|
|
|
it('not warning with getContainer', () => {
|
2023-06-07 21:59:21 +08:00
|
|
|
const errorSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
|
2022-12-02 22:44:16 +08:00
|
|
|
resetWarned();
|
|
|
|
|
|
|
|
render(<Drawer getContainer={() => document.body} />);
|
|
|
|
expect(errorSpy).not.toHaveBeenCalled();
|
|
|
|
|
|
|
|
errorSpy.mockRestore();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('not warning with getContainer false', () => {
|
2023-06-07 21:59:21 +08:00
|
|
|
const errorSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
|
2022-12-02 22:44:16 +08:00
|
|
|
resetWarned();
|
|
|
|
|
|
|
|
render(<Drawer getContainer={false} />);
|
|
|
|
expect(errorSpy).not.toHaveBeenCalled();
|
|
|
|
|
|
|
|
errorSpy.mockRestore();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('warning with getContainer & style', () => {
|
2023-06-07 21:59:21 +08:00
|
|
|
const errorSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
|
2022-12-02 22:44:16 +08:00
|
|
|
resetWarned();
|
|
|
|
|
|
|
|
render(<Drawer getContainer={false} style={{ position: 'absolute' }} />);
|
|
|
|
expect(errorSpy).toHaveBeenCalledWith(
|
2022-12-03 19:36:03 +08:00
|
|
|
'Warning: [antd: Drawer] `style` is replaced by `rootStyle` in v5. Please check that `position: absolute` is necessary.',
|
2022-12-02 22:44:16 +08:00
|
|
|
);
|
|
|
|
|
|
|
|
errorSpy.mockRestore();
|
|
|
|
});
|
2023-06-14 22:37:00 +08:00
|
|
|
|
2024-03-22 21:29:19 +08:00
|
|
|
it('should hide close button when closeIcon is null or false', () => {
|
2023-06-14 22:37:00 +08:00
|
|
|
const { baseElement, rerender } = render(
|
|
|
|
<Drawer open closeIcon={null}>
|
|
|
|
Here is content of Drawer
|
|
|
|
</Drawer>,
|
|
|
|
);
|
|
|
|
expect(baseElement.querySelector('.ant-drawer-close')).toBeNull();
|
|
|
|
|
|
|
|
rerender(
|
|
|
|
<Drawer open closeIcon={false}>
|
|
|
|
Here is content of Drawer
|
|
|
|
</Drawer>,
|
|
|
|
);
|
|
|
|
expect(baseElement.querySelector('.ant-drawer-close')).toBeNull();
|
|
|
|
|
|
|
|
rerender(
|
|
|
|
<Drawer open closeIcon={<span className="custom-close">Close</span>}>
|
|
|
|
Here is content of Drawer
|
|
|
|
</Drawer>,
|
|
|
|
);
|
|
|
|
expect(baseElement.querySelector('.custom-close')).not.toBeNull();
|
|
|
|
|
|
|
|
rerender(
|
|
|
|
<Drawer open closable={false} closeIcon={<span className="custom-close2">Close</span>}>
|
|
|
|
Here is content of Drawer
|
|
|
|
</Drawer>,
|
|
|
|
);
|
|
|
|
expect(baseElement.querySelector('.custom-close2')).toBeNull();
|
|
|
|
|
|
|
|
rerender(
|
|
|
|
<Drawer open closable closeIcon={<span className="custom-close3">Close</span>}>
|
|
|
|
Here is content of Drawer
|
|
|
|
</Drawer>,
|
|
|
|
);
|
|
|
|
expect(baseElement.querySelector('.custom-close3')).not.toBeNull();
|
|
|
|
|
|
|
|
rerender(
|
|
|
|
<Drawer open closeIcon={0} className="custom-drawer1">
|
|
|
|
Here is content of Drawer
|
|
|
|
</Drawer>,
|
|
|
|
);
|
|
|
|
expect(baseElement.querySelector('.custom-drawer1 .ant-drawer-close')).not.toBeNull();
|
|
|
|
expect(baseElement.querySelector('.custom-drawer1 .anticon-close')).toBeNull();
|
|
|
|
|
|
|
|
rerender(
|
|
|
|
<Drawer open closeIcon="" className="custom-drawer2">
|
|
|
|
Here is content of Drawer
|
|
|
|
</Drawer>,
|
|
|
|
);
|
|
|
|
expect(baseElement.querySelector('.custom-drawer2 .ant-drawer-close')).not.toBeNull();
|
|
|
|
expect(baseElement.querySelector('.custom-drawer2 .anticon-close')).toBeNull();
|
|
|
|
|
|
|
|
rerender(
|
|
|
|
<Drawer open closeIcon className="custom-drawer3">
|
|
|
|
Here is content of Drawer
|
|
|
|
</Drawer>,
|
|
|
|
);
|
|
|
|
expect(baseElement.querySelector('.custom-drawer3 .anticon-close')).not.toBeNull();
|
|
|
|
|
|
|
|
rerender(
|
|
|
|
<Drawer open closable>
|
|
|
|
Here is content of Drawer
|
|
|
|
</Drawer>,
|
|
|
|
);
|
|
|
|
expect(baseElement.querySelector('.anticon-close')).not.toBeNull();
|
|
|
|
});
|
2024-01-09 10:20:40 +08:00
|
|
|
|
2024-03-22 21:29:19 +08:00
|
|
|
it('match between styles and deprecated style prop', () => {
|
2024-01-09 10:20:40 +08:00
|
|
|
const initialFontSize = 10;
|
|
|
|
let fontSize1 = initialFontSize;
|
|
|
|
let fontSize2 = initialFontSize;
|
|
|
|
const getStyle1 = () => ({ fontSize: fontSize1++ });
|
|
|
|
const getStyle2 = () => ({ fontSize: fontSize2++ });
|
|
|
|
const { container: container1 } = render(
|
|
|
|
<Drawer
|
|
|
|
open
|
|
|
|
forceRender
|
|
|
|
getContainer={false}
|
|
|
|
footer="footer"
|
|
|
|
styles={{
|
|
|
|
header: getStyle1(),
|
|
|
|
body: getStyle1(),
|
|
|
|
footer: getStyle1(),
|
|
|
|
content: getStyle1(),
|
|
|
|
wrapper: getStyle1(),
|
|
|
|
mask: getStyle1(),
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<p>Some contents...</p>
|
|
|
|
</Drawer>,
|
|
|
|
);
|
|
|
|
const { container: container2 } = render(
|
|
|
|
<Drawer
|
|
|
|
open
|
|
|
|
forceRender
|
|
|
|
getContainer={false}
|
|
|
|
footer="footer"
|
|
|
|
headerStyle={getStyle2()}
|
|
|
|
bodyStyle={getStyle2()}
|
|
|
|
footerStyle={getStyle2()}
|
|
|
|
drawerStyle={getStyle2()}
|
|
|
|
contentWrapperStyle={getStyle2()}
|
|
|
|
maskStyle={getStyle2()}
|
|
|
|
>
|
|
|
|
<p>Some contents...</p>
|
|
|
|
</Drawer>,
|
|
|
|
);
|
|
|
|
expect(container1).toMatchSnapshot();
|
|
|
|
expect(container2).toMatchSnapshot();
|
|
|
|
for (let i = initialFontSize; i < fontSize1; i += 1) {
|
|
|
|
expect(container1.outerHTML).toContain(`font-size: ${i}px`);
|
|
|
|
}
|
|
|
|
for (let j = initialFontSize; j < fontSize2; j += 1) {
|
|
|
|
expect(container2.outerHTML).toContain(`font-size: ${j}px`);
|
|
|
|
}
|
|
|
|
expect(container1.outerHTML).toEqual(container2.outerHTML);
|
|
|
|
});
|
2022-12-02 22:44:16 +08:00
|
|
|
});
|
2024-02-28 15:28:25 +08:00
|
|
|
it('should support aria-* and closeIcon by closable', () => {
|
2024-02-28 14:11:15 +08:00
|
|
|
const { baseElement } = render(
|
|
|
|
<Drawer
|
|
|
|
open
|
|
|
|
closable={{
|
|
|
|
'aria-label': 'Close',
|
|
|
|
closeIcon: <span className="custom-close">Close</span>,
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
Here is content of Drawer
|
|
|
|
</Drawer>,
|
|
|
|
);
|
|
|
|
expect(baseElement.querySelector('.ant-drawer-close')).not.toBeNull();
|
|
|
|
expect(baseElement.querySelector('.custom-close')).not.toBeNull();
|
|
|
|
expect(baseElement.querySelector('*[aria-label="Close"]')).not.toBeNull();
|
|
|
|
});
|
2024-05-30 20:45:47 +08:00
|
|
|
|
|
|
|
it('drawerRender', () => {
|
|
|
|
const { container } = render(
|
|
|
|
<Drawer open getContainer={false} drawerRender={(dom) => <div id="test">{dom}</div>}>
|
|
|
|
Here is content of Drawer
|
|
|
|
</Drawer>,
|
|
|
|
);
|
|
|
|
|
|
|
|
triggerMotion();
|
|
|
|
expect(container.querySelector('#test')).toBeTruthy();
|
|
|
|
});
|
2018-06-19 16:47:52 +08:00
|
|
|
});
|