@@ -704,4 +704,90 @@ describeWithShallowAndMount('options.stub', mountingMethod => {
704704 `</div>`
705705 )
706706 } )
707+
708+ it ( 'stubs component inlined in render function with custom stub' , ( ) => {
709+ let childComponentCreated = false
710+ let childComponent2Created = false
711+ const ChildComponent = Vue . extend ( {
712+ name : 'child-component' ,
713+ template : '<div />' ,
714+ created ( ) {
715+ childComponentCreated = true
716+ }
717+ } )
718+ const ChildComponent2 = {
719+ name : 'child-component-2' ,
720+ template : '<div />' ,
721+ created ( ) {
722+ childComponent2Created = true
723+ }
724+ }
725+
726+ const ParentComponent = {
727+ name : 'parent-component' ,
728+ render ( h ) {
729+ return h ( 'div' , [ h ( ChildComponent ) , h ( ChildComponent2 ) ] )
730+ }
731+ }
732+
733+ const wrapper = mountingMethod ( ParentComponent , {
734+ stubs : {
735+ ChildComponent : {
736+ name : 'child-component' ,
737+ template : '<div class="stub" />'
738+ } ,
739+ ChildComponent2 : {
740+ name : 'child-component-2' ,
741+ template : '<div class="stub-2" />'
742+ }
743+ }
744+ } )
745+
746+ expect ( childComponentCreated ) . toBe ( false )
747+ expect ( childComponent2Created ) . toBe ( false )
748+
749+ expect ( wrapper . find ( '.stub' ) . exists ( ) ) . toBe ( true )
750+ expect ( wrapper . find ( '.stub-2' ) . exists ( ) ) . toBe ( true )
751+ expect ( wrapper . find ( ChildComponent ) . exists ( ) ) . toBe ( true )
752+ expect ( wrapper . find ( ChildComponent2 ) . exists ( ) ) . toBe ( true )
753+ } )
754+
755+ it ( 'stubs component inlined in render function with default stub' , ( ) => {
756+ let childComponentCreated = false
757+ let childComponent2Created = false
758+ const ChildComponent = Vue . extend ( {
759+ name : 'child-component' ,
760+ template : '<div />' ,
761+ created ( ) {
762+ childComponentCreated = true
763+ }
764+ } )
765+ const ChildComponent2 = {
766+ name : 'child-component-2' ,
767+ template : '<div />' ,
768+ created ( ) {
769+ childComponent2Created = true
770+ }
771+ }
772+
773+ const ParentComponent = {
774+ name : 'parent-component' ,
775+ render ( h ) {
776+ return h ( 'div' , [ h ( ChildComponent ) , h ( ChildComponent2 ) ] )
777+ }
778+ }
779+
780+ const wrapper = mountingMethod ( ParentComponent , {
781+ stubs : {
782+ ChildComponent : true ,
783+ ChildComponent2 : true
784+ }
785+ } )
786+
787+ expect ( childComponentCreated ) . toBe ( false )
788+ expect ( childComponent2Created ) . toBe ( false )
789+
790+ expect ( wrapper . find ( ChildComponent ) . exists ( ) ) . toBe ( true )
791+ expect ( wrapper . find ( ChildComponent2 ) . exists ( ) ) . toBe ( true )
792+ } )
707793} )
0 commit comments