import React from 'react'; import { mount } from 'enzyme'; import Drawer from '..'; import Button from '../../button'; class MultiDrawer extends React.Component { state = { visible: false, childrenDrawer: false }; showDrawer = () => { this.setState({ visible: true, }); }; onClose = () => { this.setState({ visible: false, }); }; showChildrenDrawer = () => { this.setState({ childrenDrawer: true, }); }; onChildrenDrawerClose = () => { this.setState({ childrenDrawer: false, }); }; render() { const { childrenDrawer, visible } = this.state; const { placement } = this.props; return (
This is two-level drawer
); } } describe('Drawer', () => { it('render right MultiDrawer', () => { const wrapper = mount(); wrapper.find('button#open_drawer').simulate('click'); wrapper.find('button#open_two_drawer').simulate('click'); const translateX = wrapper.find('.ant-drawer.test_drawer').get(0).props.style.transform; expect(translateX).toEqual('translateX(-180px)'); expect(wrapper.find('#two_drawer_text').exists()).toBe(true); }); it('render right MultiDrawer', () => { const wrapper = mount(); wrapper.find('button#open_drawer').simulate('click'); wrapper.find('button#open_two_drawer').simulate('click'); const translateX = wrapper.find('.ant-drawer.test_drawer').get(0).props.style.transform; expect(translateX).toEqual('translateX(180px)'); expect(wrapper.find('#two_drawer_text').exists()).toBe(true); }); });