@@ -64,18 +64,18 @@ describeWithMountingMethods('options.stub', mountingMethod => {
6464 mountingMethod . name === 'renderToString' ,
6565 'replaces component with a component' ,
6666 ( ) => {
67+ const mounted = sinon . stub ( )
68+ const Stub = {
69+ template : '<div />' ,
70+ mounted
71+ }
6772 const wrapper = mountingMethod ( ComponentWithChild , {
6873 stubs : {
69- ChildComponent : {
70- render : h => h ( 'time' ) ,
71- mounted ( ) {
72- console . info ( 'stubbed' )
73- }
74- }
74+ ChildComponent : Stub
7575 }
7676 } )
77- expect ( wrapper . findAll ( Component ) . length ) . to . equal ( 1 )
78- expect ( info . calledWith ( 'stubbed' ) ) . to . equal ( true )
77+ expect ( wrapper . findAll ( Stub ) . length ) . to . equal ( 1 )
78+ expect ( mounted ) . calledOnce
7979 }
8080 )
8181
@@ -567,4 +567,28 @@ describeWithMountingMethods('options.stub', mountingMethod => {
567567 )
568568 expect ( HTML ) . to . contain ( 'h1' )
569569 } )
570+
571+ itDoNotRunIf (
572+ mountingMethod . name === 'renderToString' ,
573+ 'uses original component stub' , ( ) => {
574+ const Stub = {
575+ template : '<div />'
576+ }
577+ const ToStub = {
578+ template : '<div />'
579+ }
580+ const TestComponent = {
581+ template : '<div><to-stub /></div>' ,
582+ components : {
583+ ToStub
584+ }
585+ }
586+ const wrapper = mountingMethod ( TestComponent , {
587+ stubs : {
588+ ToStub : Stub
589+ }
590+ } )
591+ expect ( wrapper . find ( ToStub ) . exists ( ) ) . to . be . false
592+ expect ( wrapper . find ( Stub ) . exists ( ) ) . to . be . true
593+ } )
570594} )
0 commit comments