Skip to content

Commit

Permalink
Input bsSize now propgates correctly for css form-group-\*
Browse files Browse the repository at this point in the history
  • Loading branch information
aforty committed May 7, 2015
1 parent af4c0a0 commit 3068158
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/FormGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ class FormGroup extends React.Component {
render() {
let classes = {
'form-group': !this.props.standalone,
'form-group-lg': !this.props.standalone && this.props.bsSize === 'large',
'form-group-sm': !this.props.standalone && this.props.bsSize === 'small',
'has-feedback': this.props.hasFeedback,
'has-success': this.props.bsStyle === 'success',
'has-warning': this.props.bsStyle === 'warning',
Expand All @@ -26,6 +28,7 @@ FormGroup.defaultProps = {
FormGroup.propTypes = {
standalone: React.PropTypes.bool,
hasFeedback: React.PropTypes.bool,
bsSize: React.PropTypes.oneOf(['small', 'medium', 'large']),
bsStyle: React.PropTypes.oneOf(['success', 'warning', 'error']),
groupClassName: React.PropTypes.string
};
Expand Down
20 changes: 20 additions & 0 deletions test/FormGroupSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,26 @@ describe('FormGroup', function() {
assert.ok(ReactTestUtils.findRenderedDOMComponentWithClass(instance, 'form-group'));
});

it('renders form-group with sm or lg class when bsSize is small or large', function () {
let instance = ReactTestUtils.renderIntoDocument(
<FormGroup bsSize="small">
<span />
</FormGroup>
);

assert.ok(ReactTestUtils.findRenderedDOMComponentWithClass(instance, 'form-group'));
assert.ok(ReactTestUtils.findRenderedDOMComponentWithClass(instance, 'form-group-sm'));

instance = ReactTestUtils.renderIntoDocument(
<FormGroup bsSize="large">
<span />
</FormGroup>
);

assert.ok(ReactTestUtils.findRenderedDOMComponentWithClass(instance, 'form-group'));
assert.ok(ReactTestUtils.findRenderedDOMComponentWithClass(instance, 'form-group-lg'));
});

it('renders no form-group class when standalone', function() {
let instance = ReactTestUtils.renderIntoDocument(
<FormGroup standalone>
Expand Down
16 changes: 16 additions & 0 deletions test/InputSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,22 @@ describe('Input', function () {
assert.ok(ReactTestUtils.findRenderedDOMComponentWithClass(instance, 'input-group-addon'));
});

it('renders form-group with sm or lg class when bsSize is small or large', function () {
let instance = ReactTestUtils.renderIntoDocument(
<Input bsSize="small" />
);

assert.ok(ReactTestUtils.findRenderedDOMComponentWithClass(instance, 'form-group'));
assert.ok(ReactTestUtils.findRenderedDOMComponentWithClass(instance, 'form-group-sm'));

instance = ReactTestUtils.renderIntoDocument(
<Input bsSize="large" />
);

assert.ok(ReactTestUtils.findRenderedDOMComponentWithClass(instance, 'form-group'));
assert.ok(ReactTestUtils.findRenderedDOMComponentWithClass(instance, 'form-group-lg'));
});

it('renders input-group with sm or lg class name when bsSize is small or large', function () {
let instance = ReactTestUtils.renderIntoDocument(
<Input addonBefore="$" bsSize="small" />
Expand Down

0 comments on commit 3068158

Please sign in to comment.