1 | import React from 'react';
|
2 | import {shallow, mount} from 'enzyme';
|
3 |
|
4 | import Toggle from './toggle';
|
5 | import styles from './toggle.css';
|
6 |
|
7 | describe('Toggle', () => {
|
8 | const shallowToggle = props => shallow(<Toggle {...props}/>);
|
9 | const mountToggle = props => mount(<Toggle {...props}/>);
|
10 |
|
11 | it('should create component', () => {
|
12 | mountToggle().should.have.type(Toggle);
|
13 | });
|
14 |
|
15 | it('should wrap children with label', () => {
|
16 | shallowToggle().should.have.tagName('label');
|
17 | });
|
18 |
|
19 | it('should use passed className', () => {
|
20 | shallowToggle({
|
21 | className: 'test-class'
|
22 | }).should.have.className('test-class');
|
23 | });
|
24 |
|
25 | it('should render input with type checkbox', () => {
|
26 | const toggle = shallowToggle();
|
27 | toggle.find('input').should.have.attr('type', 'checkbox');
|
28 | });
|
29 |
|
30 | it('should render switch', () => {
|
31 | const toggle = shallowToggle();
|
32 | toggle.find(`.${styles.switch}`).should.exist;
|
33 | });
|
34 | });
|