Skip to content

Commit

Permalink
fix: return promise from render and renderToString (#1164)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: render and renderToString are now async
  • Loading branch information
eddyerburgh authored Mar 3, 2019
1 parent 4cc79e1 commit 3c597d3
Show file tree
Hide file tree
Showing 24 changed files with 581 additions and 751 deletions.
18 changes: 9 additions & 9 deletions docs/api/render.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
- `{Object|Array<string>} stubs`
- `{Vue} localVue`

- **Returns:** `{CheerioWrapper}`
- **Returns:** `{Promise<CheerioWrapper>}`

- **Options:**

Expand All @@ -36,8 +36,8 @@ import { render } from '@vue/server-test-utils'
import Foo from './Foo.vue'

describe('Foo', () => {
it('renders a div', () => {
const wrapper = render(Foo)
it('renders a div', async () => {
const wrapper = await render(Foo)
expect(wrapper.text()).toContain('<div></div>')
})
})
Expand All @@ -50,8 +50,8 @@ import { render } from '@vue/server-test-utils'
import Foo from './Foo.vue'

describe('Foo', () => {
it('renders a div', () => {
const wrapper = render(Foo, {
it('renders a div', async () => {
const wrapper = await render(Foo, {
propsData: {
color: 'red'
}
Expand All @@ -70,8 +70,8 @@ import Bar from './Bar.vue'
import FooBar from './FooBar.vue'

describe('Foo', () => {
it('renders a div', () => {
const wrapper = render(Foo, {
it('renders a div', async () => {
const wrapper = await render(Foo, {
slots: {
default: [Bar, FooBar],
fooBar: FooBar, // Will match <slot name="FooBar" />,
Expand All @@ -90,9 +90,9 @@ import { render } from '@vue/server-test-utils'
import Foo from './Foo.vue'

describe('Foo', () => {
it('renders a div', () => {
it('renders a div', async () => {
const $route = { path: 'http://www.example-path.com' }
const wrapper = render(Foo, {
const wrapper = await render(Foo, {
mocks: {
$route
}
Expand Down
26 changes: 13 additions & 13 deletions docs/api/renderToString.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
- `{Object|Array<string>} stubs`
- `{Vue} localVue`

- **Returns:** `{string}`
- **Returns:** `{Promise<string>}`

- **Options:**

Expand All @@ -34,9 +34,9 @@ import { renderToString } from '@vue/server-test-utils'
import Foo from './Foo.vue'

describe('Foo', () => {
it('renders a div', () => {
const renderedString = renderToString(Foo)
expect(renderedString).toContain('<div></div>')
it('renders a div', async () => {
const str = await renderToString(Foo)
expect(str).toContain('<div></div>')
})
})
```
Expand All @@ -48,13 +48,13 @@ import { renderToString } from '@vue/server-test-utils'
import Foo from './Foo.vue'

describe('Foo', () => {
it('renders a div', () => {
const renderedString = renderToString(Foo, {
it('renders a div', async () => {
const str = await renderToString(Foo, {
propsData: {
color: 'red'
}
})
expect(renderedString).toContain('red')
expect(str).toContain('red')
})
})
```
Expand All @@ -68,15 +68,15 @@ import Bar from './Bar.vue'
import FooBar from './FooBar.vue'

describe('Foo', () => {
it('renders a div', () => {
const renderedString = renderToString(Foo, {
it('renders a div', async () => {
const str = await renderToString(Foo, {
slots: {
default: [Bar, FooBar],
fooBar: FooBar, // Will match <slot name="FooBar" />,
foo: '<div />'
}
})
expect(renderedString).toContain('<div></div>')
expect(str).toContain('<div></div>')
})
})
```
Expand All @@ -88,14 +88,14 @@ import { renderToString } from '@vue/server-test-utils'
import Foo from './Foo.vue'

describe('Foo', () => {
it('renders a div', () => {
it('renders a div', async () => {
const $route = { path: 'http://www.example-path.com' }
const renderedString = renderToString(Foo, {
const str = await renderToString(Foo, {
mocks: {
$route
}
})
expect(renderedString).toContain($route.path)
expect(str).toContain($route.path)
})
})
```
18 changes: 9 additions & 9 deletions docs/ja/api/render.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
- `{Object|Array<string>} stubs`
- `{Vue} localVue`

- **戻り値:** `{CheerioWrapper}`
- **戻り値:** `{Promise<CheerioWrapper>}`

- **オプション:**

Expand All @@ -37,8 +37,8 @@ import { render } from '@vue/server-test-utils'
import Foo from './Foo.vue'

describe('Foo', () => {
it('renders a div', () => {
const wrapper = render(Foo)
it('renders a div', async () => {
const wrapper = await render(Foo)
expect(wrapper.text()).toContain('<div></div>')
})
})
Expand All @@ -51,8 +51,8 @@ import { render } from '@vue/server-test-utils'
import Foo from './Foo.vue'

describe('Foo', () => {
it('renders a div', () => {
const wrapper = render(Foo, {
it('renders a div', async () => {
const wrapper = await render(Foo, {
propsData: {
color: 'red'
}
Expand All @@ -71,8 +71,8 @@ import Bar from './Bar.vue'
import FooBar from './FooBar.vue'

describe('Foo', () => {
it('renders a div', () => {
const wrapper = render(Foo, {
it('renders a div', async () => {
const wrapper = await render(Foo, {
slots: {
default: [Bar, FooBar],
fooBar: FooBar, // <slot name="FooBar" /> にマッチします。
Expand All @@ -91,9 +91,9 @@ import { render } from '@vue/server-test-utils'
import Foo from './Foo.vue'

describe('Foo', () => {
it('renders a div', () => {
it('renders a div', async () => {
const $route = { path: 'http://www.example-path.com' }
const wrapper = render(Foo, {
const wrapper = await render(Foo, {
mocks: {
$route
}
Expand Down
26 changes: 13 additions & 13 deletions docs/ja/api/renderToString.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
- `{Object|Array<string>} stubs`
- `{Vue} localVue`

- **戻り値:** `{string}`
- **戻り値:** `{Promise<string>}`

- **オプション:**

Expand All @@ -34,9 +34,9 @@ import { renderToString } from '@vue/server-test-utils'
import Foo from './Foo.vue'

describe('Foo', () => {
it('renders a div', () => {
const renderedString = renderToString(Foo)
expect(renderedString).toContain('<div></div>')
it('renders a div', async () => {
const str = await renderToString(Foo)
expect(str).toContain('<div></div>')
})
})
```
Expand All @@ -48,13 +48,13 @@ import { renderToString } from '@vue/server-test-utils'
import Foo from './Foo.vue'

describe('Foo', () => {
it('renders a div', () => {
const renderedString = renderToString(Foo, {
it('renders a div', async () => {
const str = await renderToString(Foo, {
propsData: {
color: 'red'
}
})
expect(renderedString).toContain('red')
expect(str).toContain('red')
})
})
```
Expand All @@ -68,15 +68,15 @@ import Bar from './Bar.vue'
import FooBar from './FooBar.vue'

describe('Foo', () => {
it('renders a div', () => {
const renderedString = renderToString(Foo, {
it('renders a div', async () => {
const str = await renderToString(Foo, {
slots: {
default: [Bar, FooBar],
fooBar: FooBar, // <slot name="FooBar" /> にマッチします。
foo: '<div />'
}
})
expect(renderedString).toContain('<div></div>')
expect(str).toContain('<div></div>')
})
})
```
Expand All @@ -88,14 +88,14 @@ import { renderToString } from '@vue/server-test-utils'
import Foo from './Foo.vue'

describe('Foo', () => {
it('renders a div', () => {
it('renders a div', async () => {
const $route = { path: 'http://www.example-path.com' }
const renderedString = renderToString(Foo, {
const str = await renderToString(Foo, {
mocks: {
$route
}
})
expect(renderedString).toContain($route.path)
expect(str).toContain($route.path)
})
})
```
18 changes: 9 additions & 9 deletions docs/ru/api/render.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
- `{Object|Array<string>} stubs`
- `{Vue} localVue`

- **Возвращает:** `{CheerioWrapper}`
- **Возвращает:** `{Promise<CheerioWrapper>}`

- **Опции:**

Expand All @@ -36,8 +36,8 @@ import { render } from '@vue/server-test-utils'
import Foo from './Foo.vue'

describe('Foo', () => {
it('renders a div', () => {
const wrapper = render(Foo)
it('renders a div', async () => {
const wrapper = await render(Foo)
expect(wrapper.text()).toContain('<div></div>')
})
})
Expand All @@ -50,8 +50,8 @@ import { render } from '@vue/server-test-utils'
import Foo from './Foo.vue'

describe('Foo', () => {
it('renders a div', () => {
const wrapper = render(Foo, {
it('renders a div', async () => {
const wrapper = await render(Foo, {
propsData: {
color: 'red'
}
Expand All @@ -70,8 +70,8 @@ import Bar from './Bar.vue'
import FooBar from './FooBar.vue'

describe('Foo', () => {
it('renders a div', () => {
const wrapper = render(Foo, {
it('renders a div', async () => {
const wrapper = await render(Foo, {
slots: {
default: [Bar, FooBar],
fooBar: FooBar, // Будет соответствовать <slot name="FooBar" />,
Expand All @@ -90,9 +90,9 @@ import { render } from '@vue/server-test-utils'
import Foo from './Foo.vue'

describe('Foo', () => {
it('renders a div', () => {
it('renders a div', async () => {
const $route = { path: 'http://www.example-path.com' }
const wrapper = render(Foo, {
const wrapper = await render(Foo, {
mocks: {
$route
}
Expand Down
26 changes: 13 additions & 13 deletions docs/ru/api/renderToString.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
- `{Object|Array<string>} stubs`
- `{Vue} localVue`

- **Возвращает:** `{string}`
- **Возвращает:** `{Promise<string>}`

- **Опции:**

Expand All @@ -34,9 +34,9 @@ import { renderToString } from '@vue/server-test-utils'
import Foo from './Foo.vue'

describe('Foo', () => {
it('renders a div', () => {
const renderedString = renderToString(Foo)
expect(renderedString).toContain('<div></div>')
it('renders a div', async () => {
const str = await renderToString(Foo)
expect(str).toContain('<div></div>')
})
})
```
Expand All @@ -48,13 +48,13 @@ import { renderToString } from '@vue/server-test-utils'
import Foo from './Foo.vue'

describe('Foo', () => {
it('renders a div', () => {
const renderedString = renderToString(Foo, {
it('renders a div', async () => {
const str = await renderToString(Foo, {
propsData: {
color: 'red'
}
})
expect(renderedString).toContain('red')
expect(str).toContain('red')
})
})
```
Expand All @@ -68,15 +68,15 @@ import Bar from './Bar.vue'
import FooBar from './FooBar.vue'

describe('Foo', () => {
it('renders a div', () => {
const renderedString = renderToString(Foo, {
it('renders a div', async () => {
const str = await renderToString(Foo, {
slots: {
default: [Bar, FooBar],
fooBar: FooBar, // Будет соответствовать <slot name="FooBar" />,
foo: '<div />'
}
})
expect(renderedString).toContain('<div></div>')
expect(str).toContain('<div></div>')
})
})
```
Expand All @@ -88,14 +88,14 @@ import { renderToString } from '@vue/server-test-utils'
import Foo from './Foo.vue'

describe('Foo', () => {
it('renders a div', () => {
it('renders a div', async () => {
const $route = { path: 'http://www.example-path.com' }
const renderedString = renderToString(Foo, {
const str = await renderToString(Foo, {
mocks: {
$route
}
})
expect(renderedString).toContain($route.path)
expect(str).toContain($route.path)
})
})
```
Loading

0 comments on commit 3c597d3

Please sign in to comment.