Skip to content

Commit

Permalink
docs(setchecked): update setChecked docs to reflect async mode
Browse files Browse the repository at this point in the history
  • Loading branch information
AtofStryker committed Aug 16, 2020
1 parent 235d493 commit 49b4cb9
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 36 deletions.
17 changes: 11 additions & 6 deletions docs/api/wrapper/setChecked.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ Sets checked value for input element of type checkbox or radio and updates `v-mo
import { mount } from '@vue/test-utils'
import Foo from './Foo.vue'

const wrapper = mount(Foo)
const radioInput = wrapper.find('input[type="radio"]')
radioInput.setChecked()
test('setChecked demo', async () => {
const wrapper = mount(Foo)
const radioInput = wrapper.find('input[type="radio"]')
await radioInput.setChecked()
})
```

- **Note:**
Expand All @@ -24,7 +26,10 @@ When you try to set the value to state via `v-model` by `radioInput.element.chec
`checkboxInput.setChecked(checked)` is an alias of the following code.

```js
checkboxInput.element.checked = checked
checkboxInput.trigger('click')
checkboxInput.trigger('change')
async function alias() {
checkboxInput.element.checked = checked
await Vue.nextTick()
await checkboxInput.trigger('click')
await checkboxInput.trigger('change')
}
```
8 changes: 5 additions & 3 deletions docs/api/wrapper/setData.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ setData works by recursively calling Vue.set.
import { mount } from '@vue/test-utils'
import Foo from './Foo.vue'

const wrapper = mount(Foo)
await wrapper.setData({ foo: 'bar' })
expect(wrapper.vm.foo).toBe('bar')
test('setData demo', async () => {
const wrapper = mount(Foo)
await wrapper.setData({ foo: 'bar' })
expect(wrapper.vm.foo).toBe('bar')
})
```
17 changes: 11 additions & 6 deletions docs/ja/api/wrapper/setChecked.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ checkbox 型もしくは radio 型の input 要素の checked の値をセット
import { mount } from '@vue/test-utils'
import Foo from './Foo.vue'

const wrapper = mount(Foo)
const radioInput = wrapper.find('input[type="radio"]')
radioInput.setChecked()
test('setChecked demo', async () => {
const wrapper = mount(Foo)
const radioInput = wrapper.find('input[type="radio"]')
await radioInput.setChecked()
})
```

- **注:**
Expand All @@ -23,7 +25,10 @@ radioInput.setChecked()
`checkboxInput.setChecked(checked)` は以下のコードのエイリアスです。

```js
checkboxInput.element.checked = checked
checkboxInput.trigger('click')
checkboxInput.trigger('change')
async function alias() {
checkboxInput.element.checked = checked
await Vue.nextTick()
await checkboxInput.trigger('click')
await checkboxInput.trigger('change')
}
```
8 changes: 5 additions & 3 deletions docs/ja/api/wrapper/setData.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ setData は再帰的に Vue.set を実行することで動作します。
import { mount } from '@vue/test-utils'
import Foo from './Foo.vue'

const wrapper = mount(Foo)
await wrapper.setData({ foo: 'bar' })
expect(wrapper.vm.foo).toBe('bar')
test('setData demo', async () => {
const wrapper = mount(Foo)
await wrapper.setData({ foo: 'bar' })
expect(wrapper.vm.foo).toBe('bar')
})
```
17 changes: 11 additions & 6 deletions docs/ru/api/wrapper/setChecked.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@
import { mount } from '@vue/test-utils'
import Foo from './Foo.vue'

const wrapper = mount(Foo)
const radioInput = wrapper.find('input[type="radio"]')
radioInput.setChecked()
test('setChecked demo', async () => {
const wrapper = mount(Foo)
const radioInput = wrapper.find('input[type="radio"]')
await radioInput.setChecked()
})
```

- **Примечание:**
Expand All @@ -24,7 +26,10 @@ radioInput.setChecked()
`checkboxInput.setChecked(checked)` — псевдоним для следующего кода.

```js
checkboxInput.element.checked = checked
checkboxInput.trigger('click')
checkboxInput.trigger('change')
async function alias() {
checkboxInput.element.checked = checked
await Vue.nextTick()
await checkboxInput.trigger('click')
await checkboxInput.trigger('change')
}
```
8 changes: 5 additions & 3 deletions docs/ru/api/wrapper/setData.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ setData работает путём слияния существующих св
import { mount } from '@vue/test-utils'
import Foo from './Foo.vue'

const wrapper = mount(Foo)
await wrapper.setData({ foo: 'bar' })
expect(wrapper.vm.foo).toBe('bar')
test('setData demo', async () => {
const wrapper = mount(Foo)
await wrapper.setData({ foo: 'bar' })
expect(wrapper.vm.foo).toBe('bar')
})
```
17 changes: 11 additions & 6 deletions docs/zh/api/wrapper/setChecked.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@
import { mount } from '@vue/test-utils'
import Foo from './Foo.vue'

const wrapper = mount(Foo)
const radioInput = wrapper.find('input[type="radio"]')
radioInput.setChecked()
test('setChecked demo', async () => {
const wrapper = mount(Foo)
const radioInput = wrapper.find('input[type="radio"]')
await radioInput.setChecked()
})
```

- **注意:**
Expand All @@ -24,7 +26,10 @@ radioInput.setChecked()
`checkboxInput.setChecked(checked)` 是接下来这段代码的别名。

```js
checkboxInput.element.checked = checked
checkboxInput.trigger('click')
checkboxInput.trigger('change')
async function alias() {
checkboxInput.element.checked = checked
await Vue.nextTick()
await checkboxInput.trigger('click')
await checkboxInput.trigger('change')
}
```
8 changes: 5 additions & 3 deletions docs/zh/api/wrapper/setData.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
import { mount } from '@vue/test-utils'
import Foo from './Foo.vue'

const wrapper = mount(Foo)
await wrapper.setData({ foo: 'bar' })
expect(wrapper.vm.foo).toBe('bar')
test('setData demo', async () => {
const wrapper = mount(Foo)
await wrapper.setData({ foo: 'bar' })
expect(wrapper.vm.foo).toBe('bar')
})
```

0 comments on commit 49b4cb9

Please sign in to comment.