Skip to content
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

server-test-utils: render() returns Cheerio not string #1143

Merged
merged 1 commit into from
Feb 12, 2019
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/server-test-utils/package.json
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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