Skip to content

Commit 8a9757c

Browse files
wieseeddyerburgh
authored andcommittedFeb 12, 2019
feat: add correct render type (#1143)
1 parent ef613de commit 8a9757c

File tree

5 files changed

+13
-5
lines changed

5 files changed

+13
-5
lines changed
 

‎packages/server-test-utils/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
},
2525
"homepage": "https://github.com/vuejs/vue-test-utils#readme",
2626
"dependencies": {
27-
"cheerio": "^1.0.0-rc.2"
27+
"cheerio": "^1.0.0-rc.2",
28+
"@types/cheerio": "^0.22.10"
2829
},
2930
"devDependencies": {
3031
"chalk": "^2.1.0",

‎packages/server-test-utils/types/index.d.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ interface VueTestUtilsConfigOptions {
5454

5555
export declare let config: VueTestUtilsConfigOptions
5656

57-
export declare function render<V extends Vue> (component: VueClass<V>, options?: ThisTypedMountOptions<V>): string
58-
export declare function render<V extends Vue> (component: ComponentOptions<V>, options?: ThisTypedMountOptions<V>): string
59-
export declare function render (component: FunctionalComponentOptions, options?: MountOptions<Vue>): string
57+
export declare function render<V extends Vue> (component: VueClass<V>, options?: ThisTypedMountOptions<V>): Cheerio
58+
export declare function render<V extends Vue> (component: ComponentOptions<V>, options?: ThisTypedMountOptions<V>): Cheerio
59+
export declare function render (component: FunctionalComponentOptions, options?: MountOptions<Vue>): Cheerio
6060

6161
export declare function renderToString<V extends Vue> (component: VueClass<V>, options?: ThisTypedMountOptions<V>): string
6262
export declare function renderToString<V extends Vue> (component: ComponentOptions<V>, options?: ThisTypedMountOptions<V>): string

‎packages/server-test-utils/types/test/renderToString.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { normalOptions, functionalOptions, Normal, ClassComponent } from './reso
44

55
const store = new Vuex.Store({})
66

7-
render(
7+
const renderResult: Cheerio = render(
88
{
99
template: '<p>foo</p>'
1010
},

‎test/specs/render.spec.js

+2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import { render } from '~vue/server-test-utils'
2+
import Cheerio from 'cheerio'
23

34
describe('render', () => {
45
it('returns a cheerio wrapper of the rendered component', () => {
56
const TestComponent = {
67
template: '<div><h2>Test</h2><p></p><p></p></div>'
78
}
89
const wrapper = render(TestComponent)
10+
expect(wrapper).to.be.an.instanceof(Cheerio)
911
expect(wrapper.find('h2').text()).to.equal('Test')
1012
expect(wrapper.find('p').length).to.equal(2)
1113
})

‎yarn.lock

+5
Original file line numberDiff line numberDiff line change
@@ -767,6 +767,11 @@
767767
dependencies:
768768
"@types/estree" "*"
769769

770+
"@types/cheerio@^0.22.10":
771+
version "0.22.10"
772+
resolved "https://registry.yarnpkg.com/@types/cheerio/-/cheerio-0.22.10.tgz#780d552467824be4a241b29510a7873a7432c4a6"
773+
integrity sha512-fOM/Jhv51iyugY7KOBZz2ThfT1gwvsGCfWxpLpZDgkGjpEO4Le9cld07OdskikLjDUQJ43dzDaVRSFwQlpdqVg==
774+
770775
"@types/estree@*", "@types/estree@0.0.38":
771776
version "0.0.38"
772777
resolved "https://registry.yarnpkg.com/@types/estree/-/estree-0.0.38.tgz#c1be40aa933723c608820a99a373a16d215a1ca2"

0 commit comments

Comments
 (0)
Please sign in to comment.