Skip to content

Commit da7a2cb

Browse files
Jinjiangeddyerburgh
authored andcommitted
docs(zh): keep update (#662)
1 parent 19239c2 commit da7a2cb

20 files changed

+87
-144
lines changed

docs/zh/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Vue Test Utils
1+
# 介绍
22

33
Vue Test Utils 是 Vue.js 官方的单元测试实用工具库。
44

docs/zh/SUMMARY.md

Lines changed: 0 additions & 74 deletions
This file was deleted.

docs/zh/api/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66
!!!include(docs/zh/api/renderToString.md)!!!
77
!!!include(docs/zh/api/selectors.md)!!!
88
!!!include(docs/zh/api/createLocalVue.md)!!!
9-
!!!include(docs/zh/api/config.md)!!!
9+
!!!include(docs/zh/api/config.md)!!!

docs/zh/api/config.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
Vue Test Utils 包含了一个定义其选项的配置对象。
44

5+
### Vue Test Utils 配置选项
6+
57
### `stubs`
68

79
- 类型:`Object`
@@ -13,7 +15,7 @@ Vue Test Utils 包含了一个定义其选项的配置对象。
1315
存储在 `config.stubs` 中的存根会被默认使用。
1416
用到的组件存根。它们会被传入挂载选项的 `stubs` 覆写。
1517

16-
当把 `stubs` 作为一个数组传入挂载选项时,`config.stubs` 会被转换为一个数组,然后用只返回一个 `<!---->` 的基础组件进行存根。
18+
当把 `stubs` 作为一个数组传入挂载选项时,`config.stubs` 会被转换为一个数组,然后用只返回一个 `<${component name}-stub>` 的基础组件进行存根。
1719

1820
示例:
1921

@@ -77,3 +79,18 @@ VueTestUtils.config.provide['$logger'] = {
7779
}
7880
}
7981
```
82+
83+
### `logModifiedComponents`
84+
85+
- 类型:`Boolean`
86+
- 默认值:`true`
87+
88+
当被展开的子元素被自动化存根的时候记录下告警日志。设置为 `false` 时则会隐藏告警日志。和其它配置选项不同的是,它不能设置在挂载选项上。
89+
90+
示例:
91+
92+
```js
93+
import VueTestUtils from '@vue/test-utils'
94+
95+
VueTestUtils.config.logModifiedComponents = false
96+
```

docs/zh/api/createLocalVue.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,17 @@
1010
可通过 `options.localVue` 来使用:
1111

1212
```js
13-
import { createLocalVue, shallow } from '@vue/test-utils'
13+
import { createLocalVue, shallowMount } from '@vue/test-utils'
1414
import Foo from './Foo.vue'
1515

1616
const localVue = createLocalVue()
17-
const wrapper = shallow(Foo, {
17+
const wrapper = shallowMount(Foo, {
1818
localVue,
1919
mocks: { foo: true }
2020
})
2121
expect(wrapper.vm.foo).toBe(true)
2222

23-
const freshWrapper = shallow(Foo)
23+
const freshWrapper = shallowMount(Foo)
2424
expect(freshWrapper.vm.foo).toBe(false)
2525
```
2626

docs/zh/api/options.md

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# 挂载选项
22

3-
`mount``shallow` 的选项。该对象同时包含了 Vue Test Utils 挂载选项和其它选项。
3+
`mount``shallowMount` 的选项。该对象同时包含了 Vue Test Utils 挂载选项和其它选项。
44

55
- [`context`](#context)
66
- [`slots`](#slots)
@@ -48,7 +48,7 @@ expect(wrapper.is(Component)).toBe(true)
4848
import Foo from './Foo.vue'
4949
import Bar from './Bar.vue'
5050

51-
const wrapper = shallow(Component, {
51+
const wrapper = shallowMount(Component, {
5252
slots: {
5353
default: [Foo, Bar],
5454
fooBar: Foo, // 将会匹配 `<slot name="FooBar" />`。
@@ -86,7 +86,7 @@ There are three limitations.
8686
示例:
8787

8888
```js
89-
const wrapper = shallow(Component, {
89+
const wrapper = shallowMount(Component, {
9090
scopedSlots: {
9191
foo: '<p slot-scope="props">{{props.index}},{{props.text}}</p>'
9292
}
@@ -98,7 +98,7 @@ expect(wrapper.find('#fooWrapper').html()).toBe('<div id="fooWrapper"><p>0,text1
9898

9999
- 类型:`{ [name: string]: Component | boolean } | Array<string>`
100100

101-
将子组件存根。可以是一个要存根的组件名的数组或对象。如果 `stubs` 是一个数组,则每个存根都是一个 `<!---->`
101+
将子组件存根。可以是一个要存根的组件名的数组或对象。如果 `stubs` 是一个数组,则每个存根都是一个 `<${component name}-stub>`
102102

103103
示例:
104104

@@ -109,7 +109,7 @@ mount(Component, {
109109
stubs: ['registered-component']
110110
})
111111

112-
shallow(Component, {
112+
shallowMount(Component, {
113113
stubs: {
114114
// 使用一个特定的实现作为存根
115115
'registered-component': Foo,
@@ -129,7 +129,7 @@ shallow(Component, {
129129

130130
```js
131131
const $route = { path: 'http://www.example-path.com' }
132-
const wrapper = shallow(Component, {
132+
const wrapper = shallowMount(Component, {
133133
mocks: {
134134
$route
135135
}
@@ -198,14 +198,12 @@ expect(wrapper.vm.$route).toBeInstanceOf(Object)
198198
- 类型:`boolean`
199199
- 默认值:`true`
200200

201-
将所有的侦听器都设置为同步执行。
202-
203201
`sync``true` 时,这个 Vue 组件会被同步渲染。
204202
`sync``false` 时,这个 Vue 组件会被异步渲染。
205203

206204
## 其它选项
207205

208-
`mount``shallow` 的选项包含了挂载选项之外的选项时,则会将它们通过[扩展](https://vuejs.org/v2/api/#extends)覆写到其组件选项。
206+
`mount``shallowMount` 的选项包含了挂载选项之外的选项时,则会将它们通过[扩展](https://vuejs.org/v2/api/#extends)覆写到其组件选项。
209207

210208
```js
211209
const Component = {

docs/zh/api/selectors.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ export default {
3232
```
3333

3434
```js
35-
import { shallow } from '@vue/test-utils'
35+
import { shallowMount } from '@vue/test-utils'
3636
import Foo from './Foo.vue'
3737

38-
const wrapper = shallow(Foo)
38+
const wrapper = shallowMount(Foo)
3939
expect(wrapper.is(Foo)).toBe(true)
4040
```
4141

docs/zh/api/wrapper-array/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@
22

33
一个 `WrapperArray` 是一个包含 [`Wrapper`](../wrapper/README.md) 数组以及 `Wrapper` 的测试方法等对象。
44

5-
- **属性:**
5+
## 属性
66

77
### `wrappers`
88

99
`array`: 包含在 `WrapperArray` 内的 `Wrappers`
1010

11-
###`length`
11+
### `length`
1212

1313
`number`:该 `WrapperArray` 中包含的 `Wrapper` 的数量。
1414

15-
- **方法:**
15+
## 方法
1616

1717
!!!include(docs/zh/api/wrapper-array/at.md)!!!
1818
!!!include(docs/zh/api/wrapper-array/contains.md)!!!
@@ -24,4 +24,4 @@
2424
!!!include(docs/zh/api/wrapper-array/setData.md)!!!
2525
!!!include(docs/zh/api/wrapper-array/setMethods.md)!!!
2626
!!!include(docs/zh/api/wrapper-array/setProps.md)!!!
27-
!!!include(docs/zh/api/wrapper-array/trigger.md)!!!
27+
!!!include(docs/zh/api/wrapper-array/trigger.md)!!!

docs/zh/api/wrapper-array/at.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010
- **示例:**
1111

1212
```js
13-
import { shallow } from '@vue/test-utils'
13+
import { shallowMount } from '@vue/test-utils'
1414
import Foo from './Foo.vue'
1515

16-
const wrapper = shallow(Foo)
16+
const wrapper = shallowMount(Foo)
1717
const divArray = wrapper.findAll('div')
1818
const secondDiv = divArray.at(1)
1919
expect(secondDiv.is('p')).toBe(true)

docs/zh/api/wrapper-array/contains.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@
1212
- **示例:**
1313

1414
```js
15-
import { shallow } from '@vue/test-utils'
15+
import { shallowMount } from '@vue/test-utils'
1616
import Foo from './Foo.vue'
1717
import Bar from './Bar.vue'
1818

19-
const wrapper = shallow(Foo)
19+
const wrapper = shallowMount(Foo)
2020
const divArray = wrapper.findAll('div')
2121
expect(divArray.contains('p')).toBe(true)
2222
expect(divArray.contains(Bar)).toBe(true)

0 commit comments

Comments
 (0)