-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The height of the TextField was not taking into account the size of the value when the TextField was first rendered. The code looks at the height of the hintText, or, if the value has changed, it looks at the height of the value. Made changes so that the value is passed into the function that is calculating the height, both when the component is mounted, or the component is resized. I have had to skip a unit test because jsdom does not support scrollHeight. The unit test code is within the test file, and could be "unskipped" later if jsdom can do layout, or another engine is used.
- Loading branch information
1 parent
c4d994f
commit 4974ba1
Showing
2 changed files
with
45 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* eslint-env mocha */ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import {mount} from 'enzyme'; | ||
import {assert} from 'chai'; | ||
import EnhancedTextarea from './EnhancedTextarea'; | ||
import getMuiTheme from '../styles/getMuiTheme'; | ||
|
||
describe('<EnhancedTextArea />', () => { | ||
const muiTheme = getMuiTheme(); | ||
const rowHeight = 24; | ||
const mountWithContext = (node) => mount(node, { | ||
context: {muiTheme}, | ||
childContextTypes: {muiTheme: PropTypes.object}, | ||
}); | ||
|
||
it('renders with no arguments', () => { | ||
const wrapper = mountWithContext( | ||
<EnhancedTextarea /> | ||
); | ||
assert.isAbove(wrapper.find('div').length, 0); | ||
}); | ||
|
||
it('has one row initial height', () => { | ||
const wrapper = mountWithContext( | ||
<EnhancedTextarea /> | ||
); | ||
assert.strictEqual(wrapper.state().height, rowHeight); | ||
}); | ||
|
||
// This test will not succeed due to | ||
// jsdom limitations | ||
// https://github.com/tmpvar/jsdom/issues/1013 | ||
/* eslint mocha/no-skipped-tests: 0 */ | ||
it.skip('has zero initial height', () => { | ||
const wrapper = mountWithContext( | ||
<EnhancedTextarea | ||
value="A really long string that should go over multiple lines and should trigger more rows than one" | ||
/> | ||
); | ||
assert.isAbove(wrapper.state().height, rowHeight); | ||
}); | ||
}); |