Skip to content

docs: keep update #674

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
Jun 6, 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
2 changes: 1 addition & 1 deletion docs/api/mount.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,4 +126,4 @@ describe('Foo', () => {
})
```

- **See also:** [Wrapper](wrapper/README.md)
- **See also:** [Wrapper](wrapper/)
4 changes: 1 addition & 3 deletions docs/api/wrapper/find.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## find(selector)

Returns [`Wrapper`](../wrapper/) of first DOM node or Vue component matching selector.
Returns `Wrapper` of first DOM node or Vue component matching selector.

Use any valid [selector](../selectors.md).

Expand Down Expand Up @@ -30,5 +30,3 @@ expect(barByName.is(Bar)).toBe(true)
const fooRef = wrapper.find({ ref: 'foo' })
expect(fooRef.is(Foo)).toBe(true)
```

- **See also:** [Wrapper](../wrapper/)
2 changes: 0 additions & 2 deletions docs/api/wrapper/findAll.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,3 @@ expect(div.is('div')).toBe(true)
const bar = wrapper.findAll(Bar).at(0)
expect(bar.is(Bar)).toBe(true)
```

- **See also:** [Wrapper](../wrapper/)
4 changes: 1 addition & 3 deletions docs/ja/api/wrapper/find.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## find(selector)

最初の DOM ノードの [Wrapper](../wrapper/)、またはセレクタで一致した Vue コンポーネントを返します。
最初の DOM ノードの Wrapper、またはセレクタで一致した Vue コンポーネントを返します。

有効な[セレクタ](../selectors.md)を使用してください。

Expand Down Expand Up @@ -30,5 +30,3 @@ expect(barByName.is(Bar)).toBe(true)
const fooRef = wrapper.find({ ref: 'foo' })
expect(fooRef.is(Foo)).toBe(true)
```

- **参照:** [Wrapper](../wrapper/)
2 changes: 0 additions & 2 deletions docs/ja/api/wrapper/findAll.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,3 @@ expect(div.is('div')).toBe(true)
const bar = wrapper.findAll(Bar).at(0)
expect(bar.is(Bar)).toBe(true)
```

- **参照:** [Wrapper](../wrapper/)
10 changes: 5 additions & 5 deletions docs/zh/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

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

* [教程](guides/README.md)
* [教程](guides/)
* [起步](guides/getting-started.md)
* [常用技巧](guides/common-tips.md)
* [鼠标、键盘以及其它 DOM 事件](guides/dom-events.md)
Expand All @@ -13,7 +13,7 @@ Vue Test Utils 是 Vue.js 官方的单元测试实用工具库。
* [测试异步行为](guides/testing-async-components.md)
* [配合 Vue Router 使用](guides/using-with-vue-router.md)
* [配合 Vuex 实用](guides/using-with-vuex.md)
* [API](api/README.md)
* [API](api/)
* [mount](api/mount.md)
* [shallowMount](api/shallowMount.md)
* [render](api/render.md)
Expand All @@ -31,7 +31,7 @@ Vue Test Utils 是 Vue.js 官方的单元测试实用工具库。
- [provide](api/options.md#provide)
- [sync](api/options.md#sync)
- [其它选项](api/options.md#other-options)
* [Wrapper](api/wrapper/README.md)
* [Wrapper](api/wrapper/)
* [attributes](api/wrapper/attributes.md)
* [classes](api/wrapper/classes.md)
* [contains](api/wrapper/contains.md)
Expand All @@ -53,7 +53,7 @@ Vue Test Utils 是 Vue.js 官方的单元测试实用工具库。
* [text](api/wrapper/text.md)
* [trigger](api/wrapper/trigger.md)
* [isVisible](api/wrapper/isVisible.md)
* [WrapperArray](api/wrapper-array/README.md)
* [WrapperArray](api/wrapper-array/)
* [at](api/wrapper-array/at.md)
* [contains](api/wrapper-array/contains.md)
* [exists](api/wrapper/exists.md)
Expand All @@ -67,7 +67,7 @@ Vue Test Utils 是 Vue.js 官方的单元测试实用工具库。
* [setProps](api/wrapper-array/setProps.md)
* [trigger](api/wrapper-array/trigger.md)
* [isVisible](api/wrapper-array/isVisible.md)
* [组件](api/components/README.md)
* [组件](api/components/)
* [TransitionStub](api/components/TransitionStub.md)
* [TransitionGroupStub](api/components/TransitionGroupStub.md)
* [RouterLinkStub](api/components/RouterLinkStub.md)
Expand Down
4 changes: 2 additions & 2 deletions docs/zh/api/mount.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

- **用法:**

创建一个包含被挂载和渲染的 Vue 组件的 [`Wrapper`](wrapper/README.md)。
创建一个包含被挂载和渲染的 Vue 组件的 [`Wrapper`](wrapper/)。

**Without options:**

Expand Down Expand Up @@ -126,4 +126,4 @@ describe('Foo', () => {
})
```

- **延伸阅读:**[`Wrapper`](wrapper/README.md)
- **延伸阅读:**[`Wrapper`](wrapper/)
9 changes: 0 additions & 9 deletions docs/zh/api/options.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,21 +59,12 @@ const wrapper = shallowMount(Component, {
expect(wrapper.find('div')).toBe(true)
```

### 传递文本

你可以传递文本到 `slots`。
这里有一处限制。

我们不支持 PhantomJS。
你可以使用 [Puppeteer](https://github.com/karma-runner/karma-chrome-launcher#headless-chromium-with-puppeteer) 作为替代品。

## scopedSlots

- 类型:`{ [name: string]: string }`

提供一个该组件所有带作用域的插槽内容的对象。每个键对应到插槽的名字,每个值可以是一个模板字符串。

There are three limitations.
这里有三处限制。

* 该选项只支持 [email protected]+。
Expand Down
2 changes: 1 addition & 1 deletion docs/zh/api/render.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

将一个对象渲染成为一个字符串并返回一个 [cheerio 包裹器](https://github.com/cheeriojs/cheerio)。

Cheerio 是一个类似 jQuery 的库,可以在 Node.js 中游览 DOM 对象。它的 API 和 Vue Test Utils 的 [`Wrapper`](wrapper/README.md) 类似。
Cheerio 是一个类似 jQuery 的库,可以在 Node.js 中游览 DOM 对象。它的 API 和 Vue Test Utils 的 [`Wrapper`](wrapper/) 类似。

`render` 在底层使用 [`vue-server-renderer`](https://ssr.vuejs.org/zh/basic.html) 将一个组件渲染为静态的 HTML。

Expand Down
2 changes: 1 addition & 1 deletion docs/zh/api/shallowMount.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

- **用法:**

和 [`mount`](mount.md) 一样,创建一个包含被挂载和渲染的 Vue 组件的 [`Wrapper`](wrapper/README.md),不同的是被存根的子组件。
和 [`mount`](mount.md) 一样,创建一个包含被挂载和渲染的 Vue 组件的 [`Wrapper`](wrapper/),不同的是被存根的子组件。

**无选项:**

Expand Down
8 changes: 4 additions & 4 deletions docs/zh/api/wrapper-array/README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# WrapperArray

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

## 属性

### `wrappers`
### `wrappers`

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

### `length`
### `length`

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

Expand Down
4 changes: 1 addition & 3 deletions docs/zh/api/wrapper/find.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## find(selector)

返回匹配选择器的第一个 DOM 节点或 Vue 组件的 [`Wrapper`](README.md)
返回匹配选择器的第一个 DOM 节点或 Vue 组件的 `Wrapper`。

可以使用任何有效的[选择器](../selectors.md)。

Expand Down Expand Up @@ -30,5 +30,3 @@ expect(barByName.is(Bar)).toBe(true)
const fooRef = wrapper.find({ ref: 'foo' })
expect(fooRef.is(Foo)).toBe(true)
```

- **延伸阅读:**[Wrapper](README.md)
4 changes: 1 addition & 3 deletions docs/zh/api/wrapper/findAll.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## findAll(selector)

返回一个匹配选择器的 DOM 节点或 Vue 组件的 [`Wrappers`](README.md) 的 [`WrapperArray`](../wrapper-array/README.md)。
返回一个 [`WrapperArray`](../wrapper-array/)。

可以使用任何有效的[选择器](../selectors.md)。

Expand All @@ -22,5 +22,3 @@ expect(div.is('div')).toBe(true)
const bar = wrapper.findAll(Bar).at(0)
expect(bar.is(Bar)).toBe(true)
```

- **延伸阅读:**[Wrapper](README.md)
26 changes: 16 additions & 10 deletions docs/zh/guides/using-with-vuex.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
## 配合 Vuex 使用
# 配合 Vuex 使用

在本教程中,我们将会看到如何用 Vue Test Utils 测试组件中的 Vuex,以及如何测试一个 Vuex store。

## 在组件中测试 Vuex

### 伪造 Action

我们来看一些代码。
Expand Down Expand Up @@ -214,14 +216,14 @@ export default{
``` js
import { shallowMount, createLocalVue } from '@vue/test-utils'
import Vuex from 'vuex'
import Modules from '../../../src/components/Modules'
import module from '../../../src/store/module'
import MyComponent from '../../../src/components/MyComponent'
import mymodule from '../../../src/store/mymodule'

const localVue = createLocalVue()

localVue.use(Vuex)

describe('Modules.vue', () => {
describe('MyComponent.vue', () => {
let actions
let state
let store
Expand All @@ -238,23 +240,27 @@ describe('Modules.vue', () => {
}

store = new Vuex.Store({
state,
actions,
getters: module.getters
modules: {
mymodule: {
state,
actions,
getters: module.getters
}
}
})
})

it('在点击按钮时调用 action“moduleActionClick”', () => {
const wrapper = shallowMount(Modules, { store, localVue })
const wrapper = shallowMount(MyComponent, { store, localVue })
const button = wrapper.find('button')
button.trigger('click')
expect(actions.moduleActionClick).toHaveBeenCalled()
})

it('在第一个 p 标签内渲染“state.inputValue”', () => {
const wrapper = shallowMount(Modules, { store, localVue })
const wrapper = shallowMount(MyComponent, { store, localVue })
const p = wrapper.find('p')
expect(p.text()).toBe(state.module.clicks.toString())
expect(p.text()).toBe(state.clicks.toString())
})
})
```
Expand Down