1- import { createLocalVue } from '~vue/test-utils'
1+ import { createLocalVue , config } from '~vue/test-utils'
22import Component from '~resources/components/component.vue'
33import ComponentWithVuex from '~resources/components/component-with-vuex.vue'
44import {
@@ -7,6 +7,21 @@ import {
77} from '~resources/utils'
88
99describeWithMountingMethods ( 'options.mocks' , ( mountingMethod ) => {
10+ let configStubsSave
11+ // let serverConfigSave
12+
13+ beforeEach ( ( ) => {
14+ configStubsSave = config . stubs
15+ // serverConfigSave = serverConfig.stubs
16+ config . stubs = { }
17+ // serverConfig.stubs = {}
18+ } )
19+
20+ afterEach ( ( ) => {
21+ config . stubs = configStubsSave
22+ // serverConfig.stubs = serverConfigSave
23+ } )
24+
1025 it ( 'adds variables to vm when passed' , ( ) => {
1126 const TestComponent = {
1227 template : `
@@ -127,6 +142,29 @@ describeWithMountingMethods('options.mocks', (mountingMethod) => {
127142 error . restore ( )
128143 } )
129144
145+ it ( 'prioritize mounting options over config' , ( ) => {
146+ config . mocks [ '$global' ] = 'globallyMockedValue'
147+
148+ const localVue = createLocalVue ( )
149+ const TestComponent = {
150+ template : `
151+ <div>{{ $global }}</div>
152+ `
153+ }
154+
155+ const wrapper = mountingMethod ( TestComponent , {
156+ localVue,
157+ mocks : {
158+ '$global' : 'locallyMockedValue'
159+ }
160+ } )
161+ const HTML = mountingMethod . name === 'renderToString'
162+ ? wrapper
163+ : wrapper . html ( )
164+ console . log ( wrapper )
165+ expect ( HTML ) . to . contain ( 'locallyMockedValue' )
166+ } )
167+
130168 it ( 'logs that a property cannot be overwritten if there are problems writing' , ( ) => {
131169 const error = sinon . stub ( console , 'error' )
132170 const localVue = createLocalVue ( )
0 commit comments