8000 Add missing await clauses by afontcu · Pull Request #1739 · vuejs/vue-test-utils · GitHub
[go: up one dir, main page]

Skip to content

Add missing await clauses #1739

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 3 commits into from
Nov 23, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Add ja and zh
  • Loading branch information
afontcu committed Nov 22, 2020
commit 42f35c32fd8884928f0940cddfd94577c2252836
2 changes: 1 addition & 1 deletion docs/guides/dom-events.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ import YesNoComponent from '@/components/YesNoComponent'
import { mount } from '@vue/test-utils'
import sinon from 'sinon'

it('Click on yes button calls our method with argument "yes"', () => {
it('Click on yes button calls our method with argument "yes"', async () => {
const spy = sinon.spy()
const wrapper = mount(YesNoComponent, {
propsData: {
Expand Down
42 changes: 20 additions & 22 deletions docs/ja/guides/dom-events.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
```js
const wrapper = mount(MyButton)

wrapper.trigger('click')
await wrapper.trigger('click')
```

`find` メソッドは `mount` メソッドと同じように `Wrapper` を返します。 `MyComponent` 内に `button` があると仮定すると、以下のコードは、 `button` をクリックします。

```js
const wrapper = mount(MyComponent)

wrapper.find('button').trigger('click')
await wrapper.find('button').trigger('click')
```

### オプション
Expand All @@ -27,7 +27,7 @@ target を `options` オブジェクトに追加することができないこ
```js
const wrapper = mount(MyButton)

wrapper.trigger('click', { button: 0 })
await wrapper.trigger('click', { button: 0 })
```

### マウスクリックの例
Expand Down Expand Up @@ -68,18 +68,16 @@ import YesNoComponent from '@/components/YesNoComponent'
import { mount } from '@vue/test-utils'
import sinon from 'sinon'

describe('Click event', () => {
it('Click on yes button calls our method with argument "yes"', () => {
const spy = sinon.spy()
const wrapper = mount(YesNoComponent, {
propsData: {
callMe: spy
}
})
wrapper.find('button.yes').trigger('click')

spy.should.have.been.calledWith('yes')
it('Click on yes button calls our method with argument "yes"', async () => {
const spy = sinon.spy()
const wrapper = mount(YesNoComponent, {
propsData: {
callMe: spy
}
})
await wrapper.find('button.yes').trigger('click')

spy.should.have.been.calledWith('yes')
})
```

Expand Down Expand Up @@ -150,29 +148,29 @@ describe('Key event tests', () => {
expect(wrapper.vm.quantity).toBe(0)
})

it('Cursor up sets quantity to 1', () => {
it('Cursor up sets quantity to 1', async () => {
const wrapper = mount(QuantityComponent)
wrapper.trigger('keydown.up')
await wrapper.trigger('keydown.up')
expect(wrapper.vm.quantity).toBe(1)
})

it('Cursor down reduce quantity by 1', () => {
8000 it('Cursor down reduce quantity by 1', async () => {
const wrapper = mount(QuantityComponent)
wrapper.vm.quantity = 5
wrapper.trigger('keydown.down')
await wrapper.trigger('keydown.down')
expect(wrapper.vm.quantity).toBe(4)
})

it('Escape sets quantity to 0', () => {
it('Escape sets quantity to 0', async () => {
const wrapper = mount(QuantityComponent)
wrapper.vm.quantity = 5
wrapper.trigger('keydown.esc')
await wrapper.trigger('keydown.esc')
expect(wrapper.vm.quantity).toBe(0)
})

it('Magic character "a" sets quantity to 13', () => {
it('Magic character "a" sets quantity to 13', async () => {
const wrapper = mount(QuantityComponent)
wrapper.trigger('keydown', {
await wrapper.trigger('keydown', {
key: 'a'
})
expect(wrapper.vm.quantity).toBe(13)
Expand Down
42 changes: 20 additions & 22 deletions docs/zh/guides/dom-events.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@
```js
const wrapper = mount(MyButton)

wrapper.trigger('click')
await wrapper.trigger('click')
```

你应该注意到了,`find` 方法也会返回一个 `Wrapper`。假设 `MyComponent` 包含一个按钮,下面的代码会点击这个按钮。

```js
const wrapper = mount(MyComponent)

wrapper.find('button').trigger('click')
await wrapper.find('button').trigger('click')
```

### 选项
Expand All @@ -29,7 +29,7 @@ wrapper.find('button').trigger('click')
```js
const wrapper = mount(MyButton)

wrapper.trigger('click', { button: 0 })
await wrapper.trigger('click', { button: 0 })
```

### 鼠标点击示例
Expand Down Expand Up @@ -73,18 +73,16 @@ import YesNoComponent from '@/components/YesNoComponent'
import { mount } from '@vue/test-utils'
import sinon from 'sinon'

describe('Click event', () => {
it('Click on yes button calls our method with argument "yes"', () => {
const spy = sinon.spy()
const wrapper = mount(YesNoComponent, {
propsData: {
callMe: spy
}
})
wrapper.find('button.yes').trigger('click')

spy.should.have.been.calledWith('yes')
it('Click on yes button calls our method with argument "yes"', async () => {
const spy = sinon.spy()
const wrapper = mount(YesNoComponent, {
propsData: {
callMe: spy
}
})
await wrapper.find('button.yes').trigger('click')

spy.should.have.been.calledWith('yes')
})
```

Expand Down Expand Up @@ -158,29 +156,29 @@ describe('Key event tests', () => {
expect(wrapper.vm.quantity).toBe(0)
})

it('Up arrow key increments quantity by 1', () => {
it('Up arrow key increments quantity by 1', async () => {
const wrapper = mount(QuantityComponent)
wrapper.trigger('keydown.up')
await wrapper.trigger('keydown.up')
expect(wrapper.vm.quantity).toBe(1)
})

it('Down arrow key decrements quantity by 1', () => {
it('Down arrow key decrements quantity by 1', async () => {
const wrapper = mount(QuantityComponent)
wrapper.vm.quantity = 5
wrapper.trigger('keydown.down')
await wrapper.trigger('keydown.down')
expect(wrapper.vm.quantity).toBe(4)
})

it('Escape sets quantity to 0', () => {
it('Escape sets quantity to 0', async () => {
const wrapper = mount(QuantityComponent)
wrapper.vm.quantity = 5
wrapper.trigger('keydown.esc')
await wrapper.trigger('keydown.esc')
expect(wrapper.vm.quantity).toBe(0)
})

it('Magic character "a" sets quantity to 13', () => {
it('Magic character "a" sets quantity to 13', async () => {
const wrapper = mount(QuantityComponent)
wrapper.trigger('keydown', {
await wrapper.trigger('keydown', {
key: 'a'
})
expect(wrapper.vm.quantity).toBe(13)
Expand Down
0