import Vue from '../../dist/vue.runtime.common.js'
import renderToString from '../../packages/vue-server-renderer/basic'
describe('SSR: basicRenderer', () => {
it('should work', done => {
renderToString(new Vue({
template: `
`,
data: {
test: 'hi',
isRed: true,
imageUrl: 'https://vuejs.org/images/logo.png'
},
components: {
test: {
render () {
return this.$createElement('div', { class: ['a'] }, 'test')
}
},
testAsync (resolve) {
resolve({
render () {
return this.$createElement('span', { class: ['b'] }, 'testAsync')
}
})
}
}
}), (err, result) => {
expect(err).toBeNull()
expect(result).toContain(
'' +
'
yoyo
' +
'
' +
'
hi ' +
'
' +
'
' +
'
test
' +
'
testAsync' +
'
'
)
done()
})
})
// #5941
it('should work peoperly when accessing $ssrContext in root component', done => {
let ssrContext
renderToString(new Vue({
template: `
`,
created () {
ssrContext = this.$ssrContext
}
}), (err, result) => {
expect(err).toBeNull()
expect(ssrContext).toBeUndefined()
done()
})
})
})