Skip to content

docs: Fix incorrect API example #13

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 14, 2020
Merged
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
8 changes: 5 additions & 3 deletions src/api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -658,8 +658,10 @@ test('updates prop', async () => {
### `setValue`

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

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.

Expand Down Expand Up @@ -688,10 +690,10 @@ export default {
test('checked', async () => {
const wrapper = mount(Component)

await wrapper.find('input').setChecked(true)
await wrapper.find('input').setValue(true)
expect(wrapper.find('div')).toBeTruthy()

await wrapper.find('input').setChecked(false)
await wrapper.find('input').setValue(false)
expect(wrapper.find('div')).toBeFalsy()
})
```