Skip to content

Commit c9206c3

Browse files
committed
fix(ssr): update render tests after refactoring
1 parent 5b38902 commit c9206c3

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed

packages/server-renderer/__tests__/render.spec.ts

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -715,5 +715,63 @@ function testRender(type: string, render: typeof renderToString) {
715715
const html = await render(app)
716716
expect(html).toBe(`<div>hello</div>`)
717717
})
718+
719+
test('mixed in serverPrefetch', async () => {
720+
const msg = Promise.resolve('hello')
721+
const app = createApp({
722+
data() {
723+
return {
724+
msg: ''
725+
}
726+
},
727+
mixins: [
728+
{
729+
async serverPrefetch() {
730+
this.msg = await msg
731+
}
732+
}
733+
],
734+
render() {
735+
return h('div', this.msg)
736+
}
737+
})
738+
const html = await render(app)
739+
expect(html).toBe(`<div>hello</div>`)
740+
})
741+
742+
test('many serverPrefetch', async () => {
743+
const foo = Promise.resolve('foo')
744+
const bar = Promise.resolve('bar')
745+
const baz = Promise.resolve('baz')
746+
const app = createApp({
747+
data() {
748+
return {
749+
foo: '',
750+
bar: '',
751+
baz: ''
752+
}
753+
},
754+
mixins: [
755+
{
756+
async serverPrefetch() {
757+
this.foo = await foo
758+
}
759+
},
760+
{
761+
async serverPrefetch() {
762+
this.bar = await bar
763+
}
764+
}
765+
],
766+
async serverPrefetch() {
767+
this.baz = await baz
768+
},
769+
render() {
770+
return h('div', `${this.foo}${this.bar}${this.baz}`)
771+
}
772+
})
773+
const html = await render(app)
774+
expect(html).toBe(`<div>foobarbaz</div>`)
775+
})
718776
})
719777
}

0 commit comments

Comments
 (0)