@@ -473,7 +473,7 @@ describe('SSR: renderToString', () => {
473
473
} )
474
474
} )
475
475
476
- it ( 'renders asynchronous component' , done => {
476
+ it ( 'renders async component' , done => {
477
477
renderVmWithOptions ( {
478
478
template : `
479
479
<div>
@@ -482,11 +482,11 @@ describe('SSR: renderToString', () => {
482
482
` ,
483
483
components : {
484
484
testAsync ( resolve ) {
485
- resolve ( {
485
+ setTimeout ( ( ) => resolve ( {
486
486
render ( ) {
487
487
return this . $createElement ( 'span' , { class : [ 'b' ] } , 'testAsync' )
488
488
}
489
- } )
489
+ } ) , 1 )
490
490
}
491
491
}
492
492
} , result => {
@@ -495,55 +495,58 @@ describe('SSR: renderToString', () => {
495
495
} )
496
496
} )
497
497
498
- it ( 'renders asynchronous component (hoc)' , done => {
498
+ it ( 'renders async component (Promise, nested)' , done => {
499
+ const Foo = ( ) => Promise . resolve ( {
500
+ render : h => h ( 'div' , [ h ( 'span' , 'foo' ) , h ( Bar ) ] )
501
+ } )
502
+ const Bar = ( ) => ( {
503
+ component : Promise . resolve ( {
504
+ render : h => h ( 'span' , 'bar' )
505
+ } )
506
+ } )
499
507
renderVmWithOptions ( {
500
- template : '<test-async></test-async>' ,
501
- components : {
502
- testAsync ( resolve ) {
503
- resolve ( {
504
- render ( ) {
505
- return this . $createElement ( 'span' , { class : [ 'b' ] } , 'testAsync' )
506
- }
507
- } )
508
- }
508
+ render : h => h ( Foo )
509
+ } , res => {
510
+ expect ( res ) . toContain ( `<div data-server-rendered="true"><span>foo</span><span>bar</span></div>` )
511
+ done ( )
512
+ } )
513
+ } )
514
+
515
+ it ( 'renders async component (ES module)' , done => {
516
+ const Foo = ( ) => Promise . resolve ( {
517
+ __esModule : true ,
518
+ default : {
519
+ render : h => h ( 'div' , [ h ( 'span' , 'foo' ) , h ( Bar ) ] )
509
520
}
510
- } , result => {
511
- expect ( result ) . toContain ( '<span data-server-rendered="true" class="b">testAsync</span>' )
521
+ } )
522
+ const Bar = ( ) => ( {
523
+ component : Promise . resolve ( {
524
+ __esModule : true ,
525
+ default : {
526
+ render : h => h ( 'span' , 'bar' )
527
+ }
528
+ } )
529
+ } )
530
+ renderVmWithOptions ( {
531
+ render : h => h ( Foo )
532
+ } , res => {
533
+ expect ( res ) . toContain ( `<div data-server-rendered="true"><span>foo</span><span>bar</span></div>` )
512
534
done ( )
513
535
} )
514
536
} )
515
537
516
- it ( 'renders nested asynchronous component' , done => {
538
+ it ( 'renders async component (hoc) ' , done => {
517
539
renderVmWithOptions ( {
518
- template : `
519
- <div>
520
- <test-async></test-async>
521
- </div>
522
- ` ,
540
+ template : '<test-async></test-async>' ,
523
541
components : {
524
- testAsync ( resolve ) {
525
- const options = {
526
- template : `
527
- <span class="b">
528
- <test-sub-async></test-sub-async>
529
- </span>
530
- `
531
- }
532
-
533
- options . components = {
534
- testSubAsync ( resolve ) {
535
- resolve ( {
536
- render ( ) {
537
- return this . $createElement ( 'div' , { class : [ 'c' ] } , 'testSubAsync' )
538
- }
539
- } )
540
- }
542
+ testAsync : ( ) => Promise . resolve ( {
543
+ render ( ) {
544
+ return this . $createElement ( 'span' , { class : [ 'b' ] } , 'testAsync' )
541
545
}
542
- resolve ( options )
543
- }
546
+ } )
544
547
}
545
548
} , result => {
546
- expect ( result ) . toContain ( '<div data-server-rendered="true"><span class="b"><div class="c">testSubAsync</div></ span></div >' )
549
+ expect ( result ) . toContain ( '<span data-server-rendered="true" class="b">testAsync</ span>' )
547
550
done ( )
548
551
} )
549
552
} )
@@ -877,23 +880,6 @@ describe('SSR: renderToString', () => {
877
880
done ( )
878
881
} )
879
882
} )
880
-
881
- it ( 'render async components' , done => {
882
- const Foo = ( ) => Promise . resolve ( {
883
- render : h => h ( 'div' , [ h ( 'span' , 'foo' ) , h ( Bar ) ] )
884
- } )
885
- const Bar = ( ) => ( {
886
- component : Promise . resolve ( {
887
- render : h => h ( 'span' , 'bar' )
888
- } )
889
- } )
890
- renderVmWithOptions ( {
891
- render : h => h ( Foo )
892
- } , res => {
893
- expect ( res ) . toContain ( `<div data-server-rendered="true"><span>foo</span><span>bar</span></div>` )
894
- done ( )
895
- } )
896
- } )
897
883
} )
898
884
899
885
function renderVmWithOptions ( options , cb ) {
0 commit comments