Skip to content

Commit 49b4cb9

Browse files
committed
docs(setchecked): update setChecked docs to reflect async mode
1 parent 235d493 commit 49b4cb9

File tree

8 files changed

+64
-36
lines changed

8 files changed

+64
-36
lines changed

docs/api/wrapper/setChecked.md

+11-6
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@ Sets checked value for input element of type checkbox or radio and updates `v-mo
1212
import { mount } from '@vue/test-utils'
1313
import Foo from './Foo.vue'
1414

15-
const wrapper = mount(Foo)
16-
const radioInput = wrapper.find('input[type="radio"]')
17-
radioInput.setChecked()
15+
test('setChecked demo', async () => {
16+
const wrapper = mount(Foo)
17+
const radioInput = wrapper.find('input[type="radio"]')
18+
await radioInput.setChecked()
19+
})
1820
```
1921

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

2628
```js
27-
checkboxInput.element.checked = checked
28-
checkboxInput.trigger('click')
29-
checkboxInput.trigger('change')
29+
async function alias() {
30+
checkboxInput.element.checked = checked
31+
await Vue.nextTick()
32+
await checkboxInput.trigger('click')
33+
await checkboxInput.trigger('change')
34+
}
3035
```

docs/api/wrapper/setData.md

+5-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ setData works by recursively calling Vue.set.
1616
import { mount } from '@vue/test-utils'
1717
import Foo from './Foo.vue'
1818

19-
const wrapper = mount(Foo)
20-
await wrapper.setData({ foo: 'bar' })
21-
expect(wrapper.vm.foo).toBe('bar')
19+
test('setData demo', async () => {
20+
const wrapper = mount(Foo)
21+
await wrapper.setData({ foo: 'bar' })
22+
expect(wrapper.vm.foo).toBe('bar')
23+
})
2224
```

docs/ja/api/wrapper/setChecked.md

+11-6
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@ checkbox 型もしくは radio 型の input 要素の checked の値をセット
1111
import { mount } from '@vue/test-utils'
1212
import Foo from './Foo.vue'
1313

14-
const wrapper = mount(Foo)
15-
const radioInput = wrapper.find('input[type="radio"]')
16-
radioInput.setChecked()
14+
test('setChecked demo', async () => {
15+
const wrapper = mount(Foo)
16+
const radioInput = wrapper.find('input[type="radio"]')
17+
await radioInput.setChecked()
18+
})
1719
```
1820

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

2527
```js
26-
checkboxInput.element.checked = checked
27-
checkboxInput.trigger('click')
28-
checkboxInput.trigger('change')
28+
async function alias() {
29+
checkboxInput.element.checked = checked
30+
await Vue.nextTick()
31+
await checkboxInput.trigger('click')
32+
await checkboxInput.trigger('change')
33+
}
2934
```

docs/ja/api/wrapper/setData.md

+5-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ setData は再帰的に Vue.set を実行することで動作します。
1616
import { mount } from '@vue/test-utils'
1717
import Foo from './Foo.vue'
1818

19-
const wrapper = mount(Foo)
20-
await wrapper.setData({ foo: 'bar' })
21-
expect(wrapper.vm.foo).toBe('bar')
19+
test('setData demo', async () => {
20+
const wrapper = mount(Foo)
21+
await wrapper.setData({ foo: 'bar' })
22+
expect(wrapper.vm.foo).toBe('bar')
23+
})
2224
```

docs/ru/api/wrapper/setChecked.md

+11-6
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@
1212
import { mount } from '@vue/test-utils'
1313
import Foo from './Foo.vue'
1414

15-
const wrapper = mount(Foo)
16-
const radioInput = wrapper.find('input[type="radio"]')
17-
radioInput.setChecked()
15+
test('setChecked demo', async () => {
16+
const wrapper = mount(Foo)
17+
const radioInput = wrapper.find('input[type="radio"]')
18+
await radioInput.setChecked()
19+
})
1820
```
1921

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

2628
```js
27-
checkboxInput.element.checked = checked
28-
checkboxInput.trigger('click')
29-
checkboxInput.trigger('change')
29+
async function alias() {
30+
checkboxInput.element.checked = checked
31+
await Vue.nextTick()
32+
await checkboxInput.trigger('click')
33+
await checkboxInput.trigger('change')
34+
}
3035
```

docs/ru/api/wrapper/setData.md

+5-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ setData работает путём слияния существующих св
1818
import { mount } from '@vue/test-utils'
1919
import Foo from './Foo.vue'
2020

21-
const wrapper = mount(Foo)
22-
await wrapper.setData({ foo: 'bar' })
23-
expect(wrapper.vm.foo).toBe('bar')
21+
test('setData demo', async () => {
22+
const wrapper = mount(Foo)
23+
await wrapper.setData({ foo: 'bar' })
24+
expect(wrapper.vm.foo).toBe('bar')
25+
})
2426
```

docs/zh/api/wrapper/setChecked.md

+11-6
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@
1212
import { mount } from '@vue/test-utils'
1313
import Foo from './Foo.vue'
1414

15-
const wrapper = mount(Foo)
16-
const radioInput = wrapper.find('input[type="radio"]')
17-
radioInput.setChecked()
15+
test('setChecked demo', async () => {
16+
const wrapper = mount(Foo)
17+
const radioInput = wrapper.find('input[type="radio"]')
18+
await radioInput.setChecked()
19+
})
1820
```
1921

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

2628
```js
27-
checkboxInput.element.checked = checked
28-
checkboxInput.trigger('click')
29-
checkboxInput.trigger('change')
29+
async function alias() {
30+
checkboxInput.element.checked = checked
31+
await Vue.nextTick()
32+
await checkboxInput.trigger('click')
33+
await checkboxInput.trigger('change')
34+
}
3035
```

docs/zh/api/wrapper/setData.md

+5-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616
import { mount } from '@vue/test-utils'
1717
import Foo from './Foo.vue'
1818

19-
const wrapper = mount(Foo)
20-
await wrapper.setData({ foo: 'bar' })
21-
expect(wrapper.vm.foo).toBe('bar')
19+
test('setData demo', async () => {
20+
const wrapper = mount(Foo)
21+
await wrapper.setData({ foo: 'bar' })
22+
expect(wrapper.vm.foo).toBe('bar')
23+
})
2224
```

0 commit comments

Comments
 (0)