Skip to content

Commit

Permalink
fix: support setValue on textarea (#764)
Browse files Browse the repository at this point in the history
  • Loading branch information
mya-ake authored and eddyerburgh committed Jun 27, 2018
1 parent 6fa6ecd commit e83cda2
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/test-utils/src/wrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,7 @@ export default class Wrapper implements BaseWrapper {
`type="radio" /> element. Use wrapper.setChecked() ` +
`instead`
)
} else if (tagName === 'INPUT' || tagName === 'textarea') {
} else if (tagName === 'INPUT' || tagName === 'TEXTAREA') {
// $FlowIgnore
this.element.value = value
this.trigger('input')
Expand Down
2 changes: 2 additions & 0 deletions test/resources/components/component-with-input.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<input type="radio" v-model="radioVal" id="radioFoo" value="radioFooResult">
<input type="radio" v-model="radioVal" id="radioBar" value="radioBarResult">
<input type="text" v-model="textVal">
<textarea v-model="textareaVal"></textarea>
<select v-model="selectVal">
<option value="selectA"></option>
<option value="selectB"></option>
Expand Down Expand Up @@ -35,6 +36,7 @@
return {
checkboxVal: undefined,
textVal: undefined,
textareaVal: undefined,
radioVal: undefined,
selectVal: undefined,
counter: 0
Expand Down
10 changes: 9 additions & 1 deletion test/specs/wrapper/setValue.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,22 @@ import ComponentWithInput from '~resources/components/component-with-input.vue'
import { describeWithShallowAndMount } from '~resources/utils'

describeWithShallowAndMount('setValue', mountingMethod => {
it('sets element value', () => {
it('sets element of input value', () => {
const wrapper = mountingMethod(ComponentWithInput)
const input = wrapper.find('input[type="text"]')
input.setValue('foo')

expect(input.element.value).to.equal('foo')
})

it('sets element of textarea value', () => {
const wrapper = mountingMethod(ComponentWithInput)
const textarea = wrapper.find('textarea')
textarea.setValue('foo')

expect(textarea.element.value).to.equal('foo')
})

it('updates dom with v-model', () => {
const wrapper = mountingMethod(ComponentWithInput)
const input = wrapper.find('input[type="text"]')
Expand Down

0 comments on commit e83cda2

Please sign in to comment.