@@ -2,19 +2,24 @@ import mount from '~src/mount'
22import ComponentWithChild from '~resources/components/component-with-child.vue'
33import ComponentWithNestedChildren from '~resources/components/component-with-nested-children.vue'
44import Component from '~resources/components/component.vue'
5+ import config from '~src/config'
56
67describe ( 'mount.stub' , ( ) => {
78 let info
89 let warn
10+ let configStubsSave
911
1012 beforeEach ( ( ) => {
1113 info = sinon . stub ( console , 'info' )
1214 warn = sinon . stub ( console , 'error' )
15+ configStubsSave = config . stubs
16+ config . stubs = { }
1317 } )
1418
1519 afterEach ( ( ) => {
1620 info . restore ( )
1721 warn . restore ( )
22+ config . stubs = configStubsSave
1823 } )
1924
2025 it ( 'replaces component with template string ' , ( ) => {
@@ -101,7 +106,7 @@ describe('mount.stub', () => {
101106 render : h => h ( 'registered-component' )
102107 }
103108 const invalidValues = [ { } , [ ] , 3 ]
104- const error = '[vue-test-utils]: each item in options.stub must be a string'
109+ const error = '[vue-test-utils]: each item in an options.stubs array must be a string'
105110 invalidValues . forEach ( invalidValue => {
106111 const fn = ( ) => mount ( ComponentWithGlobalComponent , {
107112 stubs : [ invalidValue ]
@@ -129,6 +134,13 @@ describe('mount.stub', () => {
129134 }
130135 require . cache [ require . resolve ( 'vue-template-compiler' ) ] . exports . compileToFunctions = compilerSave
131136 } )
137+ it ( 'does not stub component when set to false' , ( ) => {
138+ const wrapper = mount ( ComponentWithChild , {
139+ stubs : {
140+ ChildComponent : false
141+ } } )
142+ expect ( wrapper . find ( 'span' ) . contains ( 'div' ) ) . to . equal ( true )
143+ } )
132144
133145 it ( 'throws an error when passed an invalid value as stub' , ( ) => {
134146 const error = '[vue-test-utils]: options.stub values must be passed a string or component'
0 commit comments