Skip to content

Commit

Permalink
fix(FormField): pass content prop through (#2212)
Browse files Browse the repository at this point in the history
  • Loading branch information
levithomason authored Oct 18, 2017
1 parent d651ce9 commit 19c9434
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/collections/Form/FormField.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ function FormField(props) {
// ----------------------------------------
// Checkbox/Radio Control
// ----------------------------------------
const controlProps = { ...rest, children, disabled, required, type }
const controlProps = { ...rest, content, children, disabled, required, type }

// wrap HTML checkboxes/radios in the label
if (control === 'input' && (type === 'checkbox' || type === 'radio')) {
Expand Down
18 changes: 18 additions & 0 deletions test/specs/collections/Form/FormField-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import React from 'react'
import Radio from 'src/addons/Radio/Radio'
import FormField from 'src/collections/Form/FormField'
import { SUI } from 'src/lib'
import Button from 'src/elements/Button/Button'
import Checkbox from 'src/modules/Checkbox/Checkbox'
import * as common from 'test/specs/commonTests'

Expand Down Expand Up @@ -113,4 +114,21 @@ describe('FormField', () => {
input.should.have.prop('required', true)
})
})

describe('content', () => {
it('is not set by default', () => {
const wrapper = shallow(<FormField control={Button} />)
const button = wrapper.find('Button')

wrapper.should.have.exactly(1).descendants('Button')
button.should.not.have.prop('content')
})
it('is passed to the control', () => {
const wrapper = shallow(<FormField control={Button} content='Click Me' />)
const button = wrapper.find('Button')

wrapper.should.have.exactly(1).descendants('Button')
button.should.have.prop('content', 'Click Me')
})
})
})

0 comments on commit 19c9434

Please sign in to comment.