Wei Zhu
6 years ago
42 changed files with 887 additions and 190 deletions
@ -0,0 +1,221 @@ |
|||
version: 2 |
|||
|
|||
references: |
|||
container_config: &container_config |
|||
docker: |
|||
- image: circleci/node:8 |
|||
working_directory: ~/ant-design |
|||
|
|||
attach_workspace: &attach_workspace |
|||
attach_workspace: |
|||
at: ~/ant-design |
|||
|
|||
install_react: &install_react |
|||
run: REACT=15 ./scripts/install-react.sh |
|||
|
|||
react_15: &react_15 |
|||
environment: |
|||
REACT: 15 |
|||
|
|||
react_16: &react_16 |
|||
environment: |
|||
REACT: 16 |
|||
|
|||
jobs: |
|||
setup: |
|||
<<: *container_config |
|||
steps: |
|||
- checkout |
|||
- run: node -v |
|||
- run: npm -v |
|||
- run: npm install |
|||
- run: |
|||
command: | |
|||
set +eo |
|||
npm ls |
|||
true |
|||
- persist_to_workspace: |
|||
root: ~/ant-design |
|||
paths: |
|||
- node_modules |
|||
|
|||
dist: |
|||
<<: *container_config |
|||
steps: |
|||
- checkout |
|||
- *attach_workspace |
|||
- run: npm run dist |
|||
- run: node ./tests/dekko/dist.test.js |
|||
- persist_to_workspace: |
|||
root: ~/ant-design |
|||
paths: |
|||
- dist |
|||
|
|||
compile: |
|||
<<: *container_config |
|||
steps: |
|||
- checkout |
|||
- *attach_workspace |
|||
- run: npm run compile |
|||
- run: node ./tests/dekko/lib.test.js |
|||
- persist_to_workspace: |
|||
root: ~/ant-design |
|||
paths: |
|||
- lib |
|||
- es |
|||
|
|||
lint: |
|||
<<: *container_config |
|||
steps: |
|||
- checkout |
|||
- *attach_workspace |
|||
- run: npm run lint |
|||
|
|||
test_dist: |
|||
<<: *container_config |
|||
<<: *react_16 |
|||
steps: |
|||
- checkout |
|||
- *attach_workspace |
|||
- run: |
|||
command: npm test -- -w 2 |
|||
environment: |
|||
LIB_DIR: dist |
|||
|
|||
test_lib: |
|||
<<: *container_config |
|||
<<: *react_16 |
|||
steps: |
|||
- checkout |
|||
- *attach_workspace |
|||
- run: |
|||
command: npm test -- -w 2 |
|||
environment: |
|||
LIB_DIR: lib |
|||
|
|||
test_es: |
|||
<<: *container_config |
|||
<<: *react_16 |
|||
steps: |
|||
- checkout |
|||
- *attach_workspace |
|||
- run: |
|||
command: npm test -- -w 2 |
|||
environment: |
|||
LIB_DIR: es |
|||
|
|||
test_dom: |
|||
<<: *container_config |
|||
<<: *react_16 |
|||
steps: |
|||
- checkout |
|||
- *attach_workspace |
|||
- run: npm test -- -w 2 --coverage |
|||
- run: bash <(curl -s https://codecov.io/bash) |
|||
|
|||
test_node: |
|||
<<: *container_config |
|||
<<: *react_16 |
|||
steps: |
|||
- checkout |
|||
- *attach_workspace |
|||
- run: npm run test-node -- -w 2 |
|||
|
|||
test_dist_15: |
|||
<<: *container_config |
|||
<<: *react_15 |
|||
steps: |
|||
- checkout |
|||
- *attach_workspace |
|||
- *install_react |
|||
- run: |
|||
command: npm test -- -w 2 -u |
|||
environment: |
|||
LIB_DIR: dist |
|||
|
|||
test_lib_15: |
|||
<<: *container_config |
|||
<<: *react_15 |
|||
steps: |
|||
- checkout |
|||
- *attach_workspace |
|||
- *install_react |
|||
- run: |
|||
command: npm test -- -w 2 -u |
|||
environment: |
|||
LIB_DIR: lib |
|||
|
|||
test_es_15: |
|||
<<: *container_config |
|||
<<: *react_15 |
|||
steps: |
|||
- checkout |
|||
- *attach_workspace |
|||
- *install_react |
|||
- run: |
|||
command: npm test -- -w 2 -u |
|||
environment: |
|||
LIB_DIR: es |
|||
|
|||
test_dom_15: |
|||
<<: *container_config |
|||
<<: *react_15 |
|||
steps: |
|||
- checkout |
|||
- *attach_workspace |
|||
- *install_react |
|||
- run: npm test -- -w 2 -u |
|||
|
|||
test_node_15: |
|||
<<: *container_config |
|||
<<: *react_15 |
|||
steps: |
|||
- checkout |
|||
- *attach_workspace |
|||
- *install_react |
|||
- run: npm run test-node -- -w 2 -u |
|||
|
|||
workflows: |
|||
version: 2 |
|||
build-test: |
|||
jobs: |
|||
- setup |
|||
- dist: |
|||
requires: |
|||
- setup |
|||
- compile: |
|||
requires: |
|||
- setup |
|||
- lint: |
|||
requires: |
|||
- setup |
|||
- test_dist: |
|||
requires: |
|||
- dist |
|||
- test_lib: |
|||
requires: |
|||
- compile |
|||
- test_es: |
|||
requires: |
|||
- compile |
|||
- test_dom: |
|||
requires: |
|||
- setup |
|||
- test_node: |
|||
requires: |
|||
- setup |
|||
- test_dist_15: |
|||
requires: |
|||
- dist |
|||
- test_lib_15: |
|||
requires: |
|||
- compile |
|||
- test_es_15: |
|||
requires: |
|||
- compile |
|||
- test_dom_15: |
|||
requires: |
|||
- setup |
|||
- test_node_15: |
|||
requires: |
|||
- setup |
@ -0,0 +1,116 @@ |
|||
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 ( |
|||
<div> |
|||
<Button type="primary" id="open_drawer" onClick={this.showDrawer}> |
|||
Open drawer |
|||
</Button> |
|||
<Drawer |
|||
title="Multi-level drawer" |
|||
wrapClassName="test_drawer" |
|||
width={520} |
|||
closable={false} |
|||
onClose={this.onClose} |
|||
getContainer={false} |
|||
placement={placement} |
|||
visible={visible} |
|||
> |
|||
<Button type="primary" id="open_two_drawer" onClick={this.showChildrenDrawer}> |
|||
Two-level drawer |
|||
</Button> |
|||
<Drawer |
|||
title="Two-level Drawer" |
|||
width={320} |
|||
closable={false} |
|||
getContainer={false} |
|||
placement={placement} |
|||
onClose={this.onChildrenDrawerClose} |
|||
visible={childrenDrawer} |
|||
> |
|||
<div id="two_drawer_text"> |
|||
This is two-level drawer |
|||
</div> |
|||
</Drawer> |
|||
<div |
|||
style={{ |
|||
position: 'absolute', |
|||
bottom: 0, |
|||
width: '100%', |
|||
borderTop: '1px solid #e8e8e8', |
|||
padding: '10px 16px', |
|||
textAlign: 'right', |
|||
left: 0, |
|||
background: '#fff', |
|||
borderRadius: '0 0 4px 4px', |
|||
}} |
|||
> |
|||
<Button |
|||
style={{ |
|||
marginRight: 8, |
|||
}} |
|||
onClick={this.onClose} |
|||
> |
|||
Cancel |
|||
</Button> |
|||
<Button onClick={this.onClose} type="primary"> |
|||
Submit |
|||
</Button> |
|||
</div> |
|||
</Drawer> |
|||
</div> |
|||
); |
|||
} |
|||
} |
|||
|
|||
describe('Drawer', () => { |
|||
it('render right MultiDrawer', () => { |
|||
const wrapper = mount(<MultiDrawer placement="right" />); |
|||
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(<MultiDrawer placement="left" />); |
|||
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); |
|||
}); |
|||
}); |
File diff suppressed because it is too large
@ -1,11 +1,18 @@ |
|||
import createReactContext from 'create-react-context/lib/implementation'; |
|||
|
|||
const React = require.requireActual('react'); |
|||
|
|||
if (!React.createContext) { |
|||
React.createContext = () => { |
|||
const Provider = ({ children }) => children; |
|||
const Consumer = ({ children }) => children(); |
|||
return { Provider, Consumer }; |
|||
React.createContext = createReactContext; |
|||
} |
|||
|
|||
if (!React.createRef) { |
|||
React.createRef = () => { |
|||
const ref = function setRef(node) { |
|||
ref.current = node; |
|||
}; |
|||
return ref; |
|||
}; |
|||
} |
|||
|
|||
module.exports = React; |
|||
Object.assign(module.exports, React); |
|||
|
Loading…
Reference in new issue