Skip to content

Commit e83cda2

Browse files
mya-akeeddyerburgh
authored andcommitted
fix: support setValue on textarea (#764)
1 parent 6fa6ecd commit e83cda2

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

Diff for: packages/test-utils/src/wrapper.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -699,7 +699,7 @@ export default class Wrapper implements BaseWrapper {
699699
`type="radio" /> element. Use wrapper.setChecked() ` +
700700
`instead`
701701
)
702-
} else if (tagName === 'INPUT' || tagName === 'textarea') {
702+
} else if (tagName === 'INPUT' || tagName === 'TEXTAREA') {
703703
// $FlowIgnore
704704
this.element.value = value
705705
this.trigger('input')

Diff for: test/resources/components/component-with-input.vue

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
<input type="radio" v-model="radioVal" id="radioFoo" value="radioFooResult">
55
<input type="radio" v-model="radioVal" id="radioBar" value="radioBarResult">
66
<input type="text" v-model="textVal">
7+
<textarea v-model="textareaVal"></textarea>
78
<select v-model="selectVal">
89
<option value="selectA"></option>
910
<option value="selectB"></option>
@@ -35,6 +36,7 @@
3536
return {
3637
checkboxVal: undefined,
3738
textVal: undefined,
39+
textareaVal: undefined,
3840
radioVal: undefined,
3941
selectVal: undefined,
4042
counter: 0

Diff for: test/specs/wrapper/setValue.spec.js

+9-1
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,22 @@ import ComponentWithInput from '~resources/components/component-with-input.vue'
22
import { describeWithShallowAndMount } from '~resources/utils'
33

44
describeWithShallowAndMount('setValue', mountingMethod => {
5-
it('sets element value', () => {
5+
it('sets element of input value', () => {
66
const wrapper = mountingMethod(ComponentWithInput)
77
const input = wrapper.find('input[type="text"]')
88
input.setValue('foo')
99

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

13+
it('sets element of textarea value', () => {
14+
const wrapper = mountingMethod(ComponentWithInput)
15+
const textarea = wrapper.find('textarea')
16+
textarea.setValue('foo')
17+
18+
expect(textarea.element.value).to.equal('foo')
19+
})
20+
1321
it('updates dom with v-model', () => {
1422
const wrapper = mountingMethod(ComponentWithInput)
1523
const input = wrapper.find('input[type="text"]')

0 commit comments

Comments
 (0)