Skip to content

Commit 10fa7e2

Browse files
38elementseddyerburgh
authored andcommitted
docs: add setChecked and setValue (#799)
1 parent 4916fed commit 10fa7e2

File tree

5 files changed

+80
-1
lines changed

5 files changed

+80
-1
lines changed

Diff for: docs/README.md

+2
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,11 @@ Vue Test Utils is the official unit testing utility library for Vue.js.
6565
* [is](api/wrapper-array/is.md)
6666
* [isEmpty](api/wrapper-array/isEmpty.md)
6767
* [isVueInstance](api/wrapper-array/isVueInstance.md)
68+
* [setChecked](api/wrapper-array/setChecked.md)
6869
* [setData](api/wrapper-array/setData.md)
6970
* [setMethods](api/wrapper-array/setMethods.md)
7071
* [setProps](api/wrapper-array/setProps.md)
72+
* [setValue](api/wrapper-array/setValue.md)
7173
* [trigger](api/wrapper-array/trigger.md)
7274
* [isVisible](api/wrapper-array/isVisible.md)
7375
* [components](api/components/)

Diff for: docs/api/wrapper-array/README.md

+2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ A `WrapperArray` is an object that contains an array of [`Wrappers`](../wrapper/
2121
!!!include(docs/api/wrapper-array/is.md)!!!
2222
!!!include(docs/api/wrapper-array/isEmpty.md)!!!
2323
!!!include(docs/api/wrapper-array/isVueInstance.md)!!!
24+
!!!include(docs/api/wrapper-array/setChecked.md)!!!
2425
!!!include(docs/api/wrapper-array/setData.md)!!!
2526
!!!include(docs/api/wrapper-array/setMethods.md)!!!
2627
!!!include(docs/api/wrapper-array/setProps.md)!!!
28+
!!!include(docs/api/wrapper-array/setValue.md)!!!
2729
!!!include(docs/api/wrapper-array/trigger.md)!!!

Diff for: docs/api/wrapper-array/setChecked.md

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
## setChecked(checked)
2+
3+
This method is an alias of the following code.
4+
5+
```js
6+
wrapperArray.wrappers.forEach(wrapper => wrapper.setChecked(checked))
7+
```
8+
9+
- **Arguments:**
10+
- `{Boolean} checked (default: true)`
11+
12+
- **Example:**
13+
14+
```js
15+
import { mount } from '@vue/test-utils'
16+
17+
const wrapper = mount({
18+
data () {
19+
return {
20+
t1: false,
21+
t2: ''
22+
}
23+
},
24+
template: `
25+
<div>
26+
<input type="checkbox" name="t1" class="foo" v-model="t1" />
27+
<input type="radio" name="t2" class="foo" value="foo" v-model="t2"/>
28+
<input type="radio" name="t2" class="bar" value="bar" v-model="t2"/>
29+
</div>`
30+
})
31+
32+
const wrapperArray = wrapper.findAll('.foo')
33+
expect(wrapper.vm.t1).to.equal(false)
34+
expect(wrapper.vm.t2).to.equal('')
35+
wrapperArray.setChecked()
36+
expect(wrapper.vm.t1).to.equal(true)
37+
expect(wrapper.vm.t2).to.equal('foo')
38+
```

Diff for: docs/api/wrapper-array/setValue.md

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
## setValue(value)
2+
3+
This method is an alias of the following code.
4+
5+
```js
6+
wrapperArray.wrappers.forEach(wrapper => wrapper.setValue(value))
7+
```
8+
9+
- **Arguments:**
10+
- `{any} value`
11+
12+
- **Example:**
13+
14+
```js
15+
import { mount } from '@vue/test-utils'
16+
17+
const wrapper = mount({
18+
data () {
19+
return {
20+
t1: '',
21+
t2: ''
22+
}
23+
},
24+
template: `
25+
<div>
26+
<input type="text" name="t1" class="foo" v-model="t1" />
27+
<input type="text" name="t2" class="foo" v-model="t2"/>
28+
</div>`
29+
})
30+
31+
const wrapperArray = wrapper.findAll('.foo')
32+
expect(wrapper.vm.t1).to.equal('')
33+
expect(wrapper.vm.t2).to.equal('')
34+
wrapperArray.setValue('foo')
35+
expect(wrapper.vm.t1).to.equal('foo')
36+
expect(wrapper.vm.t2).to.equal('foo')
37+
```

Diff for: docs/api/wrapper/setValue.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Sets value of a text-control input element and updates `v-model` bound data.
44

55
- **Arguments:**
6-
- `{String} value`
6+
- `{any} value`
77

88
- **Example:**
99

0 commit comments

Comments
 (0)