File tree Expand file tree Collapse file tree 1 file changed +58
-0
lines changed
packages/server-renderer/__tests__ Expand file tree Collapse file tree 1 file changed +58
-0
lines changed Original file line number Diff line number Diff line change @@ -715,5 +715,63 @@ function testRender(type: string, render: typeof renderToString) {
715
715
const html = await render ( app )
716
716
expect ( html ) . toBe ( `<div>hello</div>` )
717
717
} )
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
+ } )
718
776
} )
719
777
}
You can’t perform that action at this time.
0 commit comments