Skip to content

Commit

Permalink
test: test for #8790
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Dec 20, 2018
1 parent ab24285 commit 7ebabe2
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
16 changes: 16 additions & 0 deletions test/ssr/fixtures/cache-opt-out.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import Vue from '../../../dist/vue.runtime.common.js'

const app = {
name: 'app',
props: ['id'],
serverCacheKey: props => props.id === 1 ? false : props.id,
render (h) {
return h('div', '/test')
}
}

export default () => {
return Promise.resolve(new Vue({
render: h => h(app, { props: { id: 1 }})
}))
}
38 changes: 38 additions & 0 deletions test/ssr/ssr-bundle-render.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,44 @@ function createAssertions (runInNewContext) {
})
})

it('render with cache (opt-out)', done => {
const cache = {}
const get = jasmine.createSpy('get')
const set = jasmine.createSpy('set')
const options = {
runInNewContext,
cache: {
// async
get: (key, cb) => {
setTimeout(() => {
get(key)
cb(cache[key])
}, 0)
},
set: (key, val) => {
set(key, val)
cache[key] = val
}
}
}
createRenderer('cache-opt-out.js', options, renderer => {
const expected = '<div data-server-rendered="true">/test</div>'
renderer.renderToString((err, res) => {
expect(err).toBeNull()
expect(res).toBe(expected)
expect(get).not.toHaveBeenCalled()
expect(set).not.toHaveBeenCalled()
renderer.renderToString((err, res) => {
expect(err).toBeNull()
expect(res).toBe(expected)
expect(get).not.toHaveBeenCalled()
expect(set).not.toHaveBeenCalled()
done()
})
})
})
})

it('renderToString (bundle format with code split)', done => {
createRenderer('split.js', { runInNewContext, asBundle: true }, renderer => {
const context = { url: '/test' }
Expand Down

0 comments on commit 7ebabe2

Please sign in to comment.