Skip to content

Commit 5686aa4

Browse files
author
Guillaume Chau
committed
test: more tests
1 parent edc3257 commit 5686aa4

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed

test/ssr/ssr-string.spec.js

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1391,6 +1391,64 @@ describe('SSR: renderToString', () => {
13911391
done()
13921392
})
13931393
})
1394+
1395+
it('should merge ssrPrefetch option', done => {
1396+
const mixin = {
1397+
data: {
1398+
message: ''
1399+
},
1400+
ssrPrefetch () {
1401+
return new Promise((resolve) => {
1402+
setTimeout(() => {
1403+
this.message = 'vue.js'
1404+
resolve()
1405+
}, 1)
1406+
})
1407+
}
1408+
}
1409+
renderVmWithOptions({
1410+
mixins: [mixin],
1411+
template: `
1412+
<div>
1413+
<span>{{ count }}</span>
1414+
<div>{{ message }}</div>
1415+
</div>
1416+
`,
1417+
data: {
1418+
count: 0
1419+
},
1420+
ssrPrefetch () {
1421+
return new Promise((resolve) => {
1422+
setTimeout(() => {
1423+
this.count = 42
1424+
resolve()
1425+
}, 1)
1426+
})
1427+
}
1428+
}, result => {
1429+
expect(result).toContain('<div data-server-rendered="true"><span>42</span> <div>vue.js</div></div>')
1430+
done()
1431+
})
1432+
})
1433+
1434+
it(`should skip ssrPrefetch option that doesn't return a promise`, done => {
1435+
renderVmWithOptions({
1436+
template: `
1437+
<div>{{ count }}</div>
1438+
`,
1439+
data: {
1440+
count: 0
1441+
},
1442+
ssrPrefetch () {
1443+
setTimeout(() => {
1444+
this.count = 42
1445+
}, 1)
1446+
}
1447+
}, result => {
1448+
expect(result).toContain('<div data-server-rendered="true">0</div>')
1449+
done()
1450+
})
1451+
})
13941452
})
13951453

13961454
function renderVmWithOptions (options, cb) {

0 commit comments

Comments
 (0)