IconMenu: active prop (#1662). more tests.
parent
74bd2dc77b
commit
bf790d7b86
|
@ -47,7 +47,7 @@ const factory = (IconButton, Menu) => {
|
|||
}
|
||||
|
||||
componentWillReceiveProps(nextProps) {
|
||||
if (nextProps.active !== this.props.active && this.state.active !== nextProps.active) {
|
||||
if (this.state.active !== nextProps.active) {
|
||||
this.setState({ active: nextProps.active });
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,6 +18,19 @@ describe('IconMenu', () => {
|
|||
const wrapper = shallow(<IconMenu active={false} />);
|
||||
expect(wrapper.find('Menu').props().active).toBe(false);
|
||||
});
|
||||
|
||||
it('sets \'active\' Menu prop correctly after IconButton click', () => {
|
||||
const wrapper = mount(<IconMenu active={false} />);
|
||||
wrapper.find('IconButton').simulate('click');
|
||||
expect(wrapper.find('Menu').props().active).toBe(true);
|
||||
});
|
||||
|
||||
it('sets \'active\' Menu prop correctly when prop is set after IconButton click', () => {
|
||||
const wrapper = mount(<IconMenu active={false} />);
|
||||
wrapper.find('IconButton').simulate('click');
|
||||
wrapper.setProps({ active: false });
|
||||
expect(wrapper.find('Menu').props().active).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('when \'active\' prop is set to true', () => {
|
||||
|
@ -31,6 +44,13 @@ describe('IconMenu', () => {
|
|||
wrapper.find('IconButton').simulate('click');
|
||||
expect(wrapper.find('Menu').props().active).toBe(false);
|
||||
});
|
||||
|
||||
it('sets \'active\' Menu prop correctly when prop is set after IconButton click', () => {
|
||||
const wrapper = mount(<IconMenu active />);
|
||||
wrapper.find('IconButton').simulate('click');
|
||||
wrapper.setProps({ active: true });
|
||||
expect(wrapper.find('Menu').props().active).toBe(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue