1 | import React from 'react';
|
2 | import {shallow, mount} from 'enzyme';
|
3 |
|
4 | import Icon from '../icon';
|
5 | import Checkbox from '../checkbox/checkbox';
|
6 |
|
7 | import ListItem from './list__item';
|
8 |
|
9 |
|
10 | describe('ListItem', () => {
|
11 | const shallowListItem = props => shallow(<ListItem {...props}/>);
|
12 | const mountListItem = props => mount(<ListItem {...props}/>);
|
13 |
|
14 |
|
15 | it('should create component', () => {
|
16 | mountListItem().should.have.type(ListItem);
|
17 | });
|
18 |
|
19 |
|
20 | it('should use passed className', () => {
|
21 | shallowListItem({className: 'test-class'}).should.
|
22 | have.className('test-class');
|
23 | });
|
24 |
|
25 |
|
26 | it('should add data test attributes', () => {
|
27 | shallowListItem().should.
|
28 | match('div[data-test="ring-list-item ring-list-item-action"]');
|
29 | });
|
30 |
|
31 |
|
32 | it('should remove ring-list-item-action data-test attribute if item is disabled', () => {
|
33 | shallowListItem({disabled: true}).should.
|
34 | match('div[data-test="ring-list-item"]');
|
35 | });
|
36 |
|
37 |
|
38 | it('should add data-test attribute if item is selected', () => {
|
39 | shallowListItem({checkbox: false}).should.
|
40 | match('div[data-test="ring-list-item ring-list-item-action"]');
|
41 |
|
42 | shallowListItem({checkbox: true}).should.
|
43 | match('div[data-test="ring-list-item ring-list-item-action ring-list-item-selected"]');
|
44 | });
|
45 |
|
46 |
|
47 | it('should render checkbox icon', () => {
|
48 | shallowListItem({checkbox: true}).
|
49 | find(Checkbox).prop('checked').should.be.true;
|
50 |
|
51 | shallowListItem({checkbox: undefined}).
|
52 | find(Checkbox).length.should.equal(0);
|
53 | });
|
54 |
|
55 |
|
56 | it('should not render check mark icon', () => {
|
57 | shallowListItem().should.not.
|
58 | containMatchingElement(<Icon/>);
|
59 | });
|
60 | });
|