@@ -4,11 +4,13 @@ import { mount, createLocalVue } from '~vue/test-utils'
44import Component from '~resources/components/component.vue'
55import ComponentWithProps from '~resources/components/component-with-props.vue'
66import ComponentWithMixin from '~resources/components/component-with-mixin.vue'
7+ import ComponentAsAClass from '~resources/components/component-as-a-class.vue'
78import { injectSupported , vueVersion } from '~resources/utils'
89import {
910 describeRunIf ,
1011 itDoNotRunIf
1112} from 'conditional-specs'
13+ import Vuex from 'vuex'
1214
1315describeRunIf ( process . env . TEST_ENV !== 'node' ,
1416 'mount' , ( ) => {
@@ -62,7 +64,12 @@ describeRunIf(process.env.TEST_ENV !== 'node',
6264
6365 it ( 'returns new VueWrapper with mounted Vue instance initialized with Vue.extend with props, if passed as propsData' , ( ) => {
6466 const prop1 = { test : 'TEST' }
65- const wrapper = mount ( Vue . extend ( ComponentWithProps ) , { propsData : { prop1 } } )
67+ const TestComponent = Vue . extend ( ComponentWithProps )
68+ const wrapper = mount ( TestComponent , {
69+ propsData : {
70+ prop1
71+ }
72+ } )
6673 expect ( wrapper . vm ) . to . be . an ( 'object' )
6774 if ( wrapper . vm . $props ) {
6875 expect ( wrapper . vm . $props . prop1 ) . to . equal ( prop1 )
@@ -131,6 +138,25 @@ describeRunIf(process.env.TEST_ENV !== 'node',
131138 expect ( wrapper . html ( ) ) . to . equal ( `<div>foo</div>` )
132139 } )
133140
141+ it ( 'overrides methods' , ( ) => {
142+ const stub = sinon . stub ( )
143+ const TestComponent = Vue . extend ( {
144+ template : '<div />' ,
145+ methods : {
146+ callStub ( ) {
147+ stub ( )
148+ }
149+ }
150+ } )
151+ mount ( TestComponent , {
152+ methods : {
153+ callStub ( ) { }
154+ }
155+ } ) . vm . callStub ( )
156+
157+ expect ( stub ) . not . called
158+ } )
159+
134160 // Problems accessing options of twice extended components in Vue < 2.3
135161 itDoNotRunIf ( vueVersion < 2.3 ,
136162 'compiles extended components' , ( ) => {
@@ -195,6 +221,20 @@ describeRunIf(process.env.TEST_ENV !== 'node',
195221 expect ( wrapper . vm . $options . listeners ) . to . equal ( undefined )
196222 } )
197223
224+ it ( 'injects store correctly' , ( ) => {
225+ const localVue = createLocalVue ( )
226+ localVue . use ( Vuex )
227+ const store = new Vuex . Store ( )
228+ const wrapper = mount ( ComponentAsAClass , {
229+ store,
230+ localVue
231+ } )
232+ wrapper . vm . getters
233+ mount ( {
234+ template : '<div>{{$store.getters}}</div>'
235+ } , { store, localVue } )
236+ } )
237+
198238 it ( 'propagates errors when they are thrown' , ( ) => {
199239 const TestComponent = {
200240 template : '<div></div>' ,
@@ -261,7 +301,7 @@ describeRunIf(process.env.TEST_ENV !== 'node',
261301 Vue . config . errorHandler = null
262302 } )
263303
264- it ( 'overwrites the component options with the options other than the mounting options when the options for mount contain those ' , ( ) => {
304+ it ( 'overwrites the component options with the instance options' , ( ) => {
265305 const Component = {
266306 template : '<div>{{ foo() }}{{ bar() }}{{ baz() }}</div>' ,
267307 methods : {
0 commit comments