Skip to content

[docs][zh-cn] synced recent updates #429

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 2 commits into from
Feb 22, 2018
Merged
Show file tree
Hide file tree
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
5 changes: 3 additions & 2 deletions docs/zh-cn/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
* [text](api/wrapper/text.md)
* [trigger](api/wrapper/trigger.md)
* [update](api/wrapper/update.md)
* [visible](api/wrapper/visible.md)
* [isVisible](api/wrapper/isVisible.md)
* [WrapperArray](api/wrapper-array/README.md)
* [at](api/wrapper-array/at.md)
* [contains](api/wrapper-array/contains.md)
Expand All @@ -66,10 +66,11 @@
* [setProps](api/wrapper-array/setProps.md)
* [trigger](api/wrapper-array/trigger.md)
* [update](api/wrapper-array/update.md)
* [visible](api/wrapper-array/visible.md)
* [isVisible](api/wrapper-array/isVisible.md)
* [组件](api/components/README.md)
* [TransitionStub](api/components/TransitionStub.md)
* [TransitionGroupStub](api/components/TransitionGroupStub.md)
* [RouterLinkStub](api/components/RouterLinkStub.md)
* [选择器](api/selectors.md)
* [createLocalVue](api/createLocalVue.md)
* [配置](api/config.md)
4 changes: 2 additions & 2 deletions docs/zh-cn/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
* [text](api/wrapper/text.md)
* [trigger](api/wrapper/trigger.md)
* [update](api/wrapper/update.md)
* [visible](api/wrapper/visible.md)
* [isVisible](api/wrapper/isVisible.md)
* [WrapperArray](api/wrapper-array/README.md)
* [at](api/wrapper-array/at.md)
* [contains](api/wrapper-array/contains.md)
Expand All @@ -62,7 +62,7 @@
* [setProps](api/wrapper-array/setProps.md)
* [trigger](api/wrapper-array/trigger.md)
* [update](api/wrapper-array/update.md)
* [visible](api/wrapper-array/visible.md)
* [isVisible](api/wrapper-array/isVisible.md)
* [组件](api/components/README.md)
* [TransitionStub](api/components/TransitionStub.md)
* [TransitionGroupStub](api/components/TransitionGroupStub.md)
Expand Down
8 changes: 3 additions & 5 deletions docs/zh-cn/api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@
* [destroy](./wrapper/destroy.md)
* [find](./wrapper/find.md)
* [findAll](./wrapper/findAll.md)
* [hasAttribute](./wrapper/hasAttribute.md)
* [hasClass](./wrapper/hasClass.md)
* [hasProp](./wrapper/hasProp.md)
* [html](./wrapper/html.md)
* [is](./wrapper/is.md)
* [isEmpty](./wrapper/isEmpty.md)
Expand All @@ -38,7 +35,7 @@
* [text](./wrapper/text.md)
* [trigger](./wrapper/trigger.md)
* [update](./wrapper/update.md)
* [visible](./wrapper/visible.md)
* [isVisible](./wrapper/isVisible.md)
* [WrapperArray](./wrapper-array/README.md)
* [at](./wrapper-array/at.md)
* [contains](./wrapper-array/contains.md)
Expand All @@ -53,10 +50,11 @@
* [setProps](./wrapper-array/setProps.md)
* [trigger](./wrapper-array/trigger.md)
* [update](./wrapper-array/update.md)
* [visible](./wrapper-array/visible.md)
* [isVisible](./wrapper-array/isVisible.md)
* [组件](./components/README.md)
* [TransitionStub](./components/TransitionStub.md)
* [TransitionGroupStub](./components/TransitionGroupStub.md)
* [RouterLinkStub](./components/RouterLinkStub.md)
* [选择器](./selectors.md)
* [createLocalVue](./createLocalVue.md)
* [配置](./config.md)
3 changes: 1 addition & 2 deletions docs/zh-cn/api/wrapper-array/filter.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
- **示例:**

```js
import { shallow } from 'vue-test-utils'
import { expect } from 'chai'
import { shallow } from '@vue/test-utils'
import Foo from './Foo.vue'

const wrapper = shallow(Foo)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# `visible()`
# `isVisible()`

断言每个 `WrapperArray` 中的每个 `Wrapper` 是否可见。

Expand All @@ -11,12 +11,12 @@
- **示例:**

```js
import { mount } from 'vue-test-utils'
import { mount } from '@vue/test-utils'
import { expect } from 'chai'
import Foo from './Foo.vue'

const wrapper = mount(Foo)
expect(wrapper.visible()).toBe(true)
expect(wrapper.findAll('.is-not-visible').visible()).toBe(false)
expect(wrapper.findAll('.is-visible').visible()).toBe(true)
expect(wrapper.isVisible()).toBe(true)
expect(wrapper.findAll('.is-not-visible').isVisible()).toBe(false)
expect(wrapper.findAll('.is-visible').isVisible()).toBe(true)
```
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# `visible()`
# `isVisible()`

断言 `Wrapper` 是否可见。

Expand All @@ -11,11 +11,11 @@
- **示例:**

```js
import { mount } from 'vue-test-utils'
import { mount } from '@vue/test-utils'
import { expect } from 'chai'
import Foo from './Foo.vue'

const wrapper = mount(Foo)
expect(wrapper.visible()).toBe(true)
expect(wrapper.find('.is-not-visible').visible()).toBe(false)
expect(wrapper.isVisible()).toBe(true)
expect(wrapper.find('.is-not-visible').isVisible()).toBe(false)
```
2 changes: 2 additions & 0 deletions docs/zh-cn/guides/using-with-vue-router.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ shallow(Component, {
})
```

> **注意:**在一个 `localVue` 上安装 Vue Router 时也会将 `$route` 和 `$router` 作为两个只读属性添加给该 `localVue`。这意味着如果你使用安装了 Vue Router 的 `localVue`,则不能在挂在一个组件时使用 `mocks` 选项来复写 `$route` 和 `$router`。
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

复写 => 覆写

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fnlctrl 我检查了一下,这个词我在别的一些地方也用了“复写” (如 config.md、optinons.md 还有 vue-cli、style-guide 等地方),另外我的输入法、百度关键字推荐等地方似乎都只有“复写”这个词。这里是否可以保持“复写”?🙂
谢谢

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

抱歉这两天没看通知:joy:

复写: 把复写纸夹在两张或几张纸之间书写,能写成一式多份(http://www.zdic.net/c/d/152/339032.htm, https://baike.baidu.com/item/%E5%A4%8D%E5%86%99)
英语中对应的是Copywriting
image

汉语词典本身没有“覆写”这个词,"覆"也没有"复"常用,所以输入法没有收录。但鉴于over是覆盖的意思,用"覆"可能更为恰当
image

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

认同。感谢指正,我稍后全局替换一下。

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


## 测试使用了 `router-link` 或 `router-view` 的组件

当你安装 Vue Router 的时候,`router-link` 和 `router-view` 组件就被注册了。这意味着我们无需再导入可以在应用的任意地方使用它们。
Expand Down
9 changes: 4 additions & 5 deletions docs/zh-cn/guides/using-with-vuex.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ describe('Getters.vue', () => {

这非常好,但是如果我们想要检查我们的 getter 是否返回了正确的 state 的部分该怎么办呢?

## 伪造 Module
### 伪造 Module

[Module](https://vuex.vuejs.org/zh-cn/modules.html) 对于将我们的 store 分隔成多个可管理的块来说非常有用。它们也暴露 getter。我们可以在测试中使用它们。

Expand Down Expand Up @@ -286,7 +286,7 @@ export default {

### 分别测试 getter、mutation 和 action

Getter、mutation 和 action 全部是 JavaScript 函数,所以我们可以不通过 `vue-test-utils` Vuex 测试它们。
Getter、mutation 和 action 全部是 JavaScript 函数,所以我们可以不通过 `vue-test-utils` Vuex 测试它们。

分别测试 getter、mutation 和 action 的好处是你的单元测试是非常详细的。当它们失败时,你完全知道你代码的问题是什么。当然另外一方面你需要伪造诸如 `commit` 和 `dispatch` 的 Vuex 函数。这会导致在一些情况下你伪造错了东西,导致单元测试通过,生产环境的代码缺失败了。

Expand Down Expand Up @@ -342,6 +342,7 @@ test('evenOrOdd returns odd if state.count is even', () => {
我们来写一个测试吧。当我们创建一个 store 时,我们会使用 `localVue` 来避免污染 Vue 的基础构造函数。该测试会使用 `store-config.js` 导出的配置创建一个 store:

```js
// store-config.spec.js
import mutations from './mutations'
import getters from './getters'

Expand All @@ -355,8 +356,6 @@ export default {
```

```js
// store-config.spec.js

import { createLocalVue } from '@vue/test-utils'
import Vuex from 'vuex'
import storeConfig from './store-config'
Expand All @@ -383,7 +382,7 @@ test('updates evenOrOdd getter when increment is commited', () => {

注意我们在创建一个 store 之前使用了 `cloneDeep` 来克隆 store 配置。这是因为 Vuex 会改变用来创建 store 的选项对象。为了确保我们能为每一个测试都提供一个干净的 store,我们需要克隆 `storeConfig` 对象。

### 相关资料
## 相关资料

- [测试组件的示例工程](https://github.com/eddyerburgh/vue-test-utils-vuex-example)
- [测试 store 的示例工程](https://github.com/eddyerburgh/testing-vuex-store-example)
Expand Down