|
| 1 | +/* eslint react/no-multi-comp: 0, react/prop-types: 0 */ |
| 2 | +import React from 'react'; |
| 3 | +import { shallow } from 'enzyme'; |
| 4 | +import { Col } from 'reactstrap';; |
| 5 | + |
| 6 | +describe('Col', () => { |
| 7 | + it('should render default .col-* markup', () => { |
| 8 | + const wrapper = shallow(<Col/>); |
| 9 | + |
| 10 | + expect(wrapper.html()).toBe('<div class="col-xs-12"></div>'); |
| 11 | + }); |
| 12 | + |
| 13 | + it('should render children', () => { |
| 14 | + const wrapper = shallow(<Col>Children</Col>); |
| 15 | + |
| 16 | + expect(wrapper.text()).toBe('Children'); |
| 17 | + }); |
| 18 | + |
| 19 | + it('should pass additional classNames', () => { |
| 20 | + const wrapper = shallow(<Col className="extra"/>); |
| 21 | + |
| 22 | + expect(wrapper.hasClass('extra')).toBe(true); |
| 23 | + expect(wrapper.hasClass('col-xs-12')).toBe(true); |
| 24 | + }); |
| 25 | + |
| 26 | + it('should pass col size specific classes as Strings', () => { |
| 27 | + const wrapper = shallow(<Col sm="6"/>); |
| 28 | + |
| 29 | + expect(wrapper.hasClass('col-sm-6')).toBe(true); |
| 30 | + expect(wrapper.hasClass('col-xs-12')).toBe(true); |
| 31 | + }); |
| 32 | + |
| 33 | + it('should pass col size specific classes as Numbers', () => { |
| 34 | + const wrapper = shallow(<Col sm={6}/>); |
| 35 | + |
| 36 | + expect(wrapper.hasClass('col-sm-6')).toBe(true); |
| 37 | + expect(wrapper.hasClass('col-xs-12')).toBe(true); |
| 38 | + }); |
| 39 | + |
| 40 | + it('should pass col size specific classes via Objects', () => { |
| 41 | + const wrapper = shallow(<Col sm={{ size: 6, push: 2, pull: 2, offset: 2 }}/>); |
| 42 | + |
| 43 | + expect(wrapper.hasClass('col-sm-6')).toBe(true); |
| 44 | + expect(wrapper.hasClass('col-xs-12')).toBe(true); |
| 45 | + expect(wrapper.hasClass('col-sm-push-2')).toBe(true); |
| 46 | + expect(wrapper.hasClass('col-sm-pull-2')).toBe(true); |
| 47 | + expect(wrapper.hasClass('col-sm-offset-2')).toBe(true); |
| 48 | + }); |
| 49 | +}); |
0 commit comments