summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorFrancesco <firefelix@gmail.com>2015-06-19 13:23:52 +0200
committerFrancesco <firefelix@gmail.com>2015-06-19 13:30:56 +0200
commitdc8075314bdf86502663fe2dbf916910d0d2b6c5 (patch)
tree14f885457558ff9a3d49040ed119a4a4d8d46e74 /test
parentd4867b2d0bc99f50781c8d577b054d034b567623 (diff)
downloadreact-autosize-textarea-dc8075314bdf86502663fe2dbf916910d0d2b6c5.zip
react-autosize-textarea-dc8075314bdf86502663fe2dbf916910d0d2b6c5.tar.gz
react-autosize-textarea-dc8075314bdf86502663fe2dbf916910d0d2b6c5.tar.bz2
Fix: was removing autosize listener with unmounted component
due to setTimeout() used needed by update event
Diffstat (limited to 'test')
-rw-r--r--test/tests/TextareaAutosize-test.js51
1 files changed, 51 insertions, 0 deletions
diff --git a/test/tests/TextareaAutosize-test.js b/test/tests/TextareaAutosize-test.js
new file mode 100644
index 0000000..4159a8e
--- /dev/null
+++ b/test/tests/TextareaAutosize-test.js
@@ -0,0 +1,51 @@
+import React from 'react/addons';
+const TestUtils = React.addons.TestUtils;
+import expect from 'expect';
+import TextareaAutosize from '../../src/TextareaAutosize';
+
+
+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');
+ // });
+
+}); \ No newline at end of file