Skip to content

Commit

Permalink
feat: add correct render type (#1143)
Browse files Browse the repository at this point in the history
  • Loading branch information
wiese authored and eddyerburgh committed Feb 12, 2019
1 parent ef613de commit 8a9757c
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 5 deletions.
3 changes: 2 additions & 1 deletion packages/server-test-utils/package.json
Expand Up @@ -24,7 +24,8 @@
},
"homepage": "https://github.com/vuejs/vue-test-utils#readme",
"dependencies": {
"cheerio": "^1.0.0-rc.2"
"cheerio": "^1.0.0-rc.2",
"@types/cheerio": "^0.22.10"
},
"devDependencies": {
"chalk": "^2.1.0",
Expand Down
6 changes: 3 additions & 3 deletions packages/server-test-utils/types/index.d.ts
Expand Up @@ -54,9 +54,9 @@ interface VueTestUtilsConfigOptions {

export declare let config: VueTestUtilsConfigOptions

export declare function render<V extends Vue> (component: VueClass<V>, options?: ThisTypedMountOptions<V>): string
export declare function render<V extends Vue> (component: ComponentOptions<V>, options?: ThisTypedMountOptions<V>): string
export declare function render (component: FunctionalComponentOptions, options?: MountOptions<Vue>): string
export declare function render<V extends Vue> (component: VueClass<V>, options?: ThisTypedMountOptions<V>): Cheerio
export declare function render<V extends Vue> (component: ComponentOptions<V>, options?: ThisTypedMountOptions<V>): Cheerio
export declare function render (component: FunctionalComponentOptions, options?: MountOptions<Vue>): Cheerio

export declare function renderToString<V extends Vue> (component: VueClass<V>, options?: ThisTypedMountOptions<V>): string
export declare function renderToString<V extends Vue> (component: ComponentOptions<V>, options?: ThisTypedMountOptions<V>): string
Expand Down
2 changes: 1 addition & 1 deletion packages/server-test-utils/types/test/renderToString.ts
Expand Up @@ -4,7 +4,7 @@ import { normalOptions, functionalOptions, Normal, ClassComponent } from './reso

const store = new Vuex.Store({})

render(
const renderResult: Cheerio = render(
{
template: '<p>foo</p>'
},
Expand Down
2 changes: 2 additions & 0 deletions test/specs/render.spec.js
@@ -1,11 +1,13 @@
import { render } from '~vue/server-test-utils'
import Cheerio from 'cheerio'

describe('render', () => {
it('returns a cheerio wrapper of the rendered component', () => {
const TestComponent = {
template: '<div><h2>Test</h2><p></p><p></p></div>'
}
const wrapper = render(TestComponent)
expect(wrapper).to.be.an.instanceof(Cheerio)
expect(wrapper.find('h2').text()).to.equal('Test')
expect(wrapper.find('p').length).to.equal(2)
})
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Expand Up @@ -767,6 +767,11 @@
dependencies:
"@types/estree" "*"

"@types/cheerio@^0.22.10":
version "0.22.10"
resolved "https://registry.yarnpkg.com/@types/cheerio/-/cheerio-0.22.10.tgz#780d552467824be4a241b29510a7873a7432c4a6"
integrity sha512-fOM/Jhv51iyugY7KOBZz2ThfT1gwvsGCfWxpLpZDgkGjpEO4Le9cld07OdskikLjDUQJ43dzDaVRSFwQlpdqVg==

"@types/estree@*", "@types/estree@0.0.38":
version "0.0.38"
resolved "https://registry.yarnpkg.com/@types/estree/-/estree-0.0.38.tgz#c1be40aa933723c608820a99a373a16d215a1ca2"
Expand Down

0 comments on commit 8a9757c

Please sign in to comment.