1 | import React from 'react';
|
2 | import {shallow, mount} from 'enzyme';
|
3 |
|
4 | import Input from './input';
|
5 |
|
6 | describe('Input', () => {
|
7 | let input;
|
8 | const inputRef = el => {
|
9 | input = el;
|
10 | };
|
11 | const shallowInput = props => shallow(<Input {...props}/>);
|
12 | const mountInput = props => mount(
|
13 | <Input
|
14 | // eslint-disable-next-line react/jsx-no-bind
|
15 | inputRef={inputRef}
|
16 | {...props}
|
17 | />
|
18 | );
|
19 |
|
20 | it('should create component', () => {
|
21 | mountInput().should.have.type(Input);
|
22 | });
|
23 |
|
24 | it('should wrap children with div', () => {
|
25 | shallowInput().should.have.tagName('div');
|
26 | });
|
27 |
|
28 | it('should create input by default', () => {
|
29 | mountInput();
|
30 | input.should.match('input');
|
31 | });
|
32 |
|
33 | it('should create textarea with multiline option', () => {
|
34 | mountInput({multiline: true});
|
35 | input.should.match('textarea');
|
36 | });
|
37 |
|
38 | it('should use passed className', () => {
|
39 | shallowInput({className: 'test-class'}).should.have.className('test-class');
|
40 | });
|
41 | });
|