Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions docs/api/wrapper/setChecked.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
## setChecked(value)
## setChecked(checked)

Sets the value of a radio or checkbox `<input>`.
Sets checked value for input element of type checkbox or radio and updates `v-model` bound data.

- **Arguments:**
- `{Boolean} selected`
- `{Boolean} checked (default: true)`

- **Example:**

Expand All @@ -16,3 +16,14 @@ const option = wrapper.find('input[type="radio"]')
option.setChecked()
```

- **Note:**

When you try to set the value to state via `v-model` by `radioInput.element.checked = true; radioInput.trigger('input')`, `v-model` is not triggered. `v-model` is triggered by `change` event.

`checkboxInput.setChecked(checked)` is an alias of the following code.

```js
checkboxInput.element.checked = checked
checkboxInput.trigger('click')
checkboxInput.trigger('change')
```
19 changes: 13 additions & 6 deletions docs/api/wrapper/setSelected.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
## setSelected(value)
## setSelected()

Sets a specified `<option>` as selected in a `<select>`.

- **Arguments:**
- `{Boolean} selected`
Selects an option element and updates `v-model` bound data.

- **Example:**

Expand All @@ -15,5 +12,15 @@ const wrapper = shallowMount(Foo)
const options = wrapper.find('select').findAll('option')

options.at(1).setSelected()
expect(wrapper.text()).to.contain('option1')
```

- **Note:**

When you try to set the value to state via `v-model` by `option.element.selected = true; parentSelect.trigger('input')`, `v-model` is not triggered. `v-model` is triggered by `change` event.

`option.setSelected()` is an alias of the following code.

```js
option.element.selected = true
parentSelect.trigger('change')
```
11 changes: 10 additions & 1 deletion docs/api/wrapper/setValue.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## setValue(value)

Sets the value of a text `<input>`.
Sets value of a text-control input element and updates `v-model` bound data.

- **Arguments:**
- `{String} value`
Expand All @@ -15,3 +15,12 @@ const wrapper = mount(Foo)
const input = wrapper.find('input[type="text"]')
input.setValue('some value')
```

- **Note:**

`textInput.setValue(value)` is an alias of the following code.

```js
textInput.element.value = value
textInput.trigger('input')
```