summaryrefslogtreecommitdiffstats
path: root/test/tests/TextareaAutosize-test.js
blob: 1c57b8ee59099dffe4204492cf9c37b900eb638b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import React from 'react';
import TestUtils from 'react-dom/test-utils';
import expect from 'expect';
import TextareaAutosize from '../../lib';


const renderTextarea = () => {
  const component = <TextareaAutosize className='textarea-autosize' />;
  const textarea = TestUtils.renderIntoDocument(component);
  return textarea;
};

describe('TextareaAutosize', () => {

  it('should be displayed', () => {
    const textarea = renderTextarea();
    const txt = TestUtils.scryRenderedDOMComponentsWithClass(textarea, 'textarea-autosize');
    expect(txt.length).toBe(1, 'textarea is not displayed');
  });

  it('should display initial value', () => {
    const initialValue = 'Initial Value';
    const component = (
      <TextareaAutosize className='textarea-autosize' defaultValue={initialValue} />
    );
    const textarea = TestUtils.renderIntoDocument(component);
    const txt = TestUtils.findRenderedDOMComponentWithClass(textarea, 'textarea-autosize');
    const value = txt.innerHTML;
    expect(value).toBe(initialValue, 'intial value is not displayed correctly');
  });

});