@@ -5,7 +5,7 @@ import ComponentAsAClass from '~resources/components/component-as-a-class.vue'
55import { createLocalVue , config } from '~vue/test-utils'
66import { config as serverConfig } from '~vue/server-test-utils'
77import Vue from 'vue'
8- import { describeWithMountingMethods } from '~resources/utils'
8+ import { describeWithMountingMethods , vueVersion } from '~resources/utils'
99import { itDoNotRunIf } from 'conditional-specs'
1010
1111describeWithMountingMethods ( 'options.stub' , mountingMethod => {
@@ -133,42 +133,70 @@ describeWithMountingMethods('options.stub', mountingMethod => {
133133 itDoNotRunIf (
134134 mountingMethod . name === 'shallowMount' ,
135135 'stubs nested components' , ( ) => {
136- const GrandchildComponent = {
136+ const GrandChildComponent = {
137137 template : '<span />'
138138 }
139139 const ChildComponent = {
140- template : '<grandchild -component />' ,
141- components : { GrandchildComponent }
140+ template : '<grand-child -component />' ,
141+ components : { GrandChildComponent }
142142 }
143143 const TestComponent = {
144144 template : '<child-component />' ,
145145 components : { ChildComponent }
146146 }
147147 const wrapper = mountingMethod ( TestComponent , {
148- stubs : [ 'grandchild -component' ]
148+ stubs : [ 'grand-child -component' ]
149149 } )
150150 const HTML = mountingMethod . name === 'renderToString'
151151 ? wrapper
152152 : wrapper . html ( )
153153 expect ( HTML ) . not . to . contain ( '<span>' )
154154 } )
155155
156+ itDoNotRunIf (
157+ mountingMethod . name === 'shallowMount' || vueVersion < 2.3 ,
158+ 'stubs nested components registered globally' , ( ) => {
159+ const GrandChildComponent = {
160+ render : h => h ( 'span' , [ 'hello' ] )
161+ }
162+ const ChildComponent = {
163+ render : h => h ( 'grand-child-component' )
164+ }
165+ const TestComponent = {
166+ render : h => h ( 'child-component' )
167+ }
168+ Vue . component ( 'child-component' , ChildComponent )
169+ Vue . component ( 'grand-child-component' , GrandChildComponent )
170+
171+ const wrapper = mountingMethod ( TestComponent , {
172+ stubs : {
173+ 'grand-child-component' : true
174+ }
175+ } )
176+ const HTML = mountingMethod . name === 'renderToString'
177+ ? wrapper
178+ : wrapper . html ( )
179+ expect ( HTML ) . not . to . contain ( '<span>' )
180+ delete Vue . options . components [ 'child-component' ]
181+ delete Vue . options . components [ 'grand-child-component' ]
182+ } )
183+
156184 itDoNotRunIf (
157185 mountingMethod . name === 'shallowMount' ,
158186 'stubs nested components on extended components' , ( ) => {
159- const GrandchildComponent = {
187+ const GrandChildComponent = {
160188 template : '<span />'
161189 }
162190 const ChildComponent = {
163- template : '<grandchild -component />' ,
164- components : { GrandchildComponent }
191+ template : '<grand-child -component />' ,
192+ components : { GrandChildComponent }
165193 }
166194 const TestComponent = {
167195 template : '<div><child-component /></div>' ,
168196 components : { ChildComponent }
169197 }
170198 const wrapper = mountingMethod ( Vue . extend ( TestComponent ) , {
171- stubs : [ 'grandchild -component' ]
199+ stubs : [ 'grand-child -component' ]
172200 } )
173201 const HTML = mountingMethod . name === 'renderToString'
174202 ? wrapper
0 commit comments