Skip to content

Commit 91c1510

Browse files
authored
Merge pull request #13 from pearofducks/improve-set-value
docs: Fix incorrect API example
2 parents 1add488 + 29b4470 commit 91c1510

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/api/README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -658,8 +658,10 @@ test('updates prop', async () => {
658658
### `setValue`
659659

660660
Sets a value on DOM element, including:
661-
- `<input>` (either `type="checkbox"` or `type="radio"`)
661+
- `<input>`
662+
- `type="checkbox"` and `type="radio"` are detected and will have `element.checked` set
662663
- `<select>`
664+
- `<option>` is detected and will have `element.selected` set
663665

664666
Since this will often result in a DOM re-render, `setValue` returns `Vue.nextTick`, so you will often have to call this with `await` to ensure the DOM has been updated before making an assertion.
665667

@@ -688,10 +690,10 @@ export default {
688690
test('checked', async () => {
689691
const wrapper = mount(Component)
690692

691-
await wrapper.find('input').setChecked(true)
693+
await wrapper.find('input').setValue(true)
692694
expect(wrapper.find('div')).toBeTruthy()
693695

694-
await wrapper.find('input').setChecked(false)
696+
await wrapper.find('input').setValue(false)
695697
expect(wrapper.find('div')).toBeFalsy()
696698
})
697699
```

0 commit comments

Comments
 (0)