|
1 | 1 | import React from 'react'; |
2 | | -import { shallow } from 'enzyme'; |
| 2 | +import { mount, shallow } from 'enzyme'; |
| 3 | +import { IconMenu } from '../IconMenu'; |
3 | 4 | import { Menu } from '../Menu'; |
4 | 5 | import { MenuItem } from '../MenuItem'; |
5 | 6 |
|
| 7 | +describe('IconMenu', () => { |
| 8 | + describe('#on mount', () => { |
| 9 | + describe('when \'active\' prop is not set', () => { |
| 10 | + it('sets \'active\' Menu prop correctly', () => { |
| 11 | + const wrapper = shallow(<IconMenu />); |
| 12 | + expect(wrapper.find('Menu').props().active).toBe(false); |
| 13 | + }); |
| 14 | + }); |
| 15 | + |
| 16 | + describe('when \'active\' prop is set to false', () => { |
| 17 | + it('sets \'active\' Menu prop correctly', () => { |
| 18 | + const wrapper = shallow(<IconMenu active={false} />); |
| 19 | + expect(wrapper.find('Menu').props().active).toBe(false); |
| 20 | + }); |
| 21 | + |
| 22 | + it('sets \'active\' Menu prop correctly after IconButton click', () => { |
| 23 | + const wrapper = mount(<IconMenu active={false} />); |
| 24 | + wrapper.find('IconButton').simulate('click'); |
| 25 | + expect(wrapper.find('Menu').props().active).toBe(true); |
| 26 | + }); |
| 27 | + |
| 28 | + it('sets \'active\' Menu prop correctly when prop is set after IconButton click', () => { |
| 29 | + const wrapper = mount(<IconMenu active={false} />); |
| 30 | + wrapper.find('IconButton').simulate('click'); |
| 31 | + wrapper.setProps({ active: false }); |
| 32 | + expect(wrapper.find('Menu').props().active).toBe(false); |
| 33 | + }); |
| 34 | + }); |
| 35 | + |
| 36 | + describe('when \'active\' prop is set to true', () => { |
| 37 | + it('sets \'active\' Menu prop correctly', () => { |
| 38 | + const wrapper = shallow(<IconMenu active />); |
| 39 | + expect(wrapper.find('Menu').props().active).toBe(true); |
| 40 | + }); |
| 41 | + |
| 42 | + it('sets \'active\' Menu prop correctly after IconButton click', () => { |
| 43 | + const wrapper = mount(<IconMenu active />); |
| 44 | + wrapper.find('IconButton').simulate('click'); |
| 45 | + expect(wrapper.find('Menu').props().active).toBe(false); |
| 46 | + }); |
| 47 | + |
| 48 | + it('sets \'active\' Menu prop correctly when prop is set after IconButton click', () => { |
| 49 | + const wrapper = mount(<IconMenu active />); |
| 50 | + wrapper.find('IconButton').simulate('click'); |
| 51 | + wrapper.setProps({ active: true }); |
| 52 | + expect(wrapper.find('Menu').props().active).toBe(true); |
| 53 | + }); |
| 54 | + }); |
| 55 | + }); |
| 56 | +}); |
| 57 | + |
6 | 58 | describe('MenuItem', () => { |
7 | 59 | describe('#onClick', () => { |
8 | 60 | it('passes to listener the event', () => { |
|
0 commit comments