diff --git a/docs/README.md b/docs/README.md index dfb548060..acf6006b7 100644 --- a/docs/README.md +++ b/docs/README.md @@ -65,9 +65,11 @@ Vue Test Utils is the official unit testing utility library for Vue.js. * [is](api/wrapper-array/is.md) * [isEmpty](api/wrapper-array/isEmpty.md) * [isVueInstance](api/wrapper-array/isVueInstance.md) + * [setChecked](api/wrapper-array/setChecked.md) * [setData](api/wrapper-array/setData.md) * [setMethods](api/wrapper-array/setMethods.md) * [setProps](api/wrapper-array/setProps.md) + * [setValue](api/wrapper-array/setValue.md) * [trigger](api/wrapper-array/trigger.md) * [isVisible](api/wrapper-array/isVisible.md) * [components](api/components/) diff --git a/docs/api/wrapper-array/README.md b/docs/api/wrapper-array/README.md index fa6c745cf..6f252df0b 100644 --- a/docs/api/wrapper-array/README.md +++ b/docs/api/wrapper-array/README.md @@ -21,7 +21,9 @@ A `WrapperArray` is an object that contains an array of [`Wrappers`](../wrapper/ !!!include(docs/api/wrapper-array/is.md)!!! !!!include(docs/api/wrapper-array/isEmpty.md)!!! !!!include(docs/api/wrapper-array/isVueInstance.md)!!! +!!!include(docs/api/wrapper-array/setChecked.md)!!! !!!include(docs/api/wrapper-array/setData.md)!!! !!!include(docs/api/wrapper-array/setMethods.md)!!! !!!include(docs/api/wrapper-array/setProps.md)!!! +!!!include(docs/api/wrapper-array/setValue.md)!!! !!!include(docs/api/wrapper-array/trigger.md)!!! diff --git a/docs/api/wrapper-array/setChecked.md b/docs/api/wrapper-array/setChecked.md new file mode 100644 index 000000000..34011cefc --- /dev/null +++ b/docs/api/wrapper-array/setChecked.md @@ -0,0 +1,38 @@ +## setChecked(checked) + +This method is an alias of the following code. + +```js +wrapperArray.wrappers.forEach(wrapper => wrapper.setChecked(checked)) +``` + +- **Arguments:** + - `{Boolean} checked (default: true)` + +- **Example:** + +```js +import { mount } from '@vue/test-utils' + +const wrapper = mount({ + data () { + return { + t1: false, + t2: '' + } + }, + template: ` +
+ + + +
` +}) + +const wrapperArray = wrapper.findAll('.foo') +expect(wrapper.vm.t1).to.equal(false) +expect(wrapper.vm.t2).to.equal('') +wrapperArray.setChecked() +expect(wrapper.vm.t1).to.equal(true) +expect(wrapper.vm.t2).to.equal('foo') +``` diff --git a/docs/api/wrapper-array/setValue.md b/docs/api/wrapper-array/setValue.md new file mode 100644 index 000000000..f19552939 --- /dev/null +++ b/docs/api/wrapper-array/setValue.md @@ -0,0 +1,37 @@ +## setValue(value) + +This method is an alias of the following code. + +```js +wrapperArray.wrappers.forEach(wrapper => wrapper.setValue(value)) +``` + +- **Arguments:** + - `{any} value` + +- **Example:** + +```js +import { mount } from '@vue/test-utils' + +const wrapper = mount({ + data () { + return { + t1: '', + t2: '' + } + }, + template: ` +
+ + +
` +}) + +const wrapperArray = wrapper.findAll('.foo') +expect(wrapper.vm.t1).to.equal('') +expect(wrapper.vm.t2).to.equal('') +wrapperArray.setValue('foo') +expect(wrapper.vm.t1).to.equal('foo') +expect(wrapper.vm.t2).to.equal('foo') +``` diff --git a/docs/api/wrapper/setValue.md b/docs/api/wrapper/setValue.md index 56f066b03..e55a91066 100644 --- a/docs/api/wrapper/setValue.md +++ b/docs/api/wrapper/setValue.md @@ -3,7 +3,7 @@ Sets value of a text-control input element and updates `v-model` bound data. - **Arguments:** - - `{String} value` + - `{any} value` - **Example:**