Skip to content
This repository has been archived by the owner on Dec 7, 2020. It is now read-only.

Commit

Permalink
Merge pull request #310 from uktrade/bug/select-option-initial-value-fix
Browse files Browse the repository at this point in the history
fix: select option fix
  • Loading branch information
paulgain authored Jun 25, 2020
2 parents 9e2c687 + 9d1c346 commit 590419a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
3 changes: 1 addition & 2 deletions src/forms/elements/FieldSelect.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ const FieldSelect = ({
meta={{ error, touched }}
input={{
id: name,
value,
readOnly: true,
defaultValue: value,
...rest,
}}
>
Expand Down
15 changes: 11 additions & 4 deletions src/forms/elements/__tests__/FieldSelect.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -175,12 +175,19 @@ describe('FieldSelect', () => {
.simulate('change', { target: { value: 'testOptionValue2' } })
})

test('should update the field value', () => {
expect(wrapper.find('select').prop('value')).toEqual('testOptionValue2')
test('should update the defaultValue', () => {
expect(wrapper.find('select').prop('defaultValue')).toEqual(
'testOptionValue2'
)
})

test('should set the readonly flag', () => {
expect(wrapper.find('select').prop('readOnly')).toEqual(true)
test('should have a selected attribute', () => {
expect(
wrapper
.find('select option')
.first()
.html()
).toContain('selected')
})

test('should update value in form state', () => {
Expand Down

0 comments on commit 590419a

Please sign in to comment.