Skip to content

Commit

Permalink
add test for htmlFor to textfield and textarea
Browse files Browse the repository at this point in the history
  • Loading branch information
zemirco committed Jan 12, 2017
1 parent 33db9b7 commit a1ccf69
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/js/textfield/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const TextfieldWrapper = ({
)
}

export const Textfield = ({float, error, length, ...rest}) => (
export const Textfield = ({float, error, length, htmlFor, ...rest}) => (
<TextfieldWrapper
defaultValue={rest.defaultValue}
error={error}
Expand All @@ -66,7 +66,7 @@ export const Textfield = ({float, error, length, ...rest}) => (
label={rest.label}
value={rest.value}
length={length}
htmlFor={rest.htmlFor}
htmlFor={htmlFor}
>
<input
className={classnames('Textfield-input', {
Expand Down
10 changes: 10 additions & 0 deletions src/js/textfield/test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@ describe('Textfield', () => {
const wrapper = mount(<Textfield type='password' />)
assert.equal(wrapper.find('.Textfield-input').node.type, 'password')
})

it('should allow setting the htmlFor attribute on label element', () => {
const wrapper = mount(<Textfield htmlFor='foo' />)
assert.equal(wrapper.find('label').node.htmlFor, 'foo')
})
})

describe('Textarea', () => {
Expand Down Expand Up @@ -168,5 +173,10 @@ describe('Textarea', () => {
wrapper.find('textarea').simulate('input', {target})
assert.equal(target.style.height, '30px')
})

it('should allow setting the htmlFor attribute on label element', () => {
const wrapper = mount(<Textarea htmlFor='foo' />)
assert.equal(wrapper.find('label').node.htmlFor, 'foo')
})
})

0 comments on commit a1ccf69

Please sign in to comment.