blob: 35b64bb52d69f2c919867e26216b8129d4da64e0 (
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
import React from 'react/addons';
const TestUtils = React.addons.TestUtils;
import expect from 'expect';
import TextareaAutosize from '../../lib';
const renderTextarea = () => {
const component =
<div>
<TextareaAutosize className='textarea-autosize' />
</div>;
const textareaWrapper = TestUtils.renderIntoDocument(component);
return textareaWrapper;
};
describe('TextareaAutosize', function() {
it('should be displayed', function() {
const textareaWrapper = renderTextarea();
const textarea = TestUtils.scryRenderedDOMComponentsWithClass(textareaWrapper, 'textarea-autosize');
expect(textarea.length).toBe(1, 'textarea is not displayed');
});
it('should display initial value', function() {
const initialValue = 'Initial Value'
const component =
<div>
<TextareaAutosize className='textarea-autosize' defaultValue={initialValue} />
</div>;
const textareaWrapper = TestUtils.renderIntoDocument(component);
const textarea = TestUtils.findRenderedDOMComponentWithClass(textareaWrapper, 'textarea-autosize');
const value = textarea.getDOMNode().innerHTML;
expect(value).toBe(initialValue, 'intial value is not displayed correctly');
});
// it('should resize correctly based on initial value', function() {
// const initialValue = '\n\n\n\n\n\n\n\n\n\nInitial Value'
// const component =
// <div>
// <TextareaAutosize className='textarea-autosize' defaultValue={initialValue} />
// </div>;
// const textareaWrapper = TestUtils.renderIntoDocument(component);
// const textarea = TestUtils.findRenderedDOMComponentWithClass(textareaWrapper, 'textarea-autosize').getDOMNode();
// React.addons.TestUtils.Simulate.click(textarea);
// console.log(textarea.style.height);
// console.log(textarea.clientHeight);
// // const value = textarea.getDOMNode().innerHTML;
// // expect(value).toBe(initialValue, 'intial value is not displayed correctly');
// });
});
|