1- import { mount } from '~vue-test-utils'
21import { createLocalVue } from '~vue-test-utils'
32import Component from '~resources/components/component.vue'
43import ComponentWithVuex from '~resources/components/component-with-vuex.vue'
4+ import {
5+ describeWithShallowAndMount ,
6+ itDoNotRunIf
7+ } from '~resources/test-utils'
58
6- describe ( 'mount .mocks', ( ) => {
9+ describeWithShallowAndMount ( 'options .mocks', ( mountingMethod ) => {
710 it ( 'adds variables to vm when passed as mocks object' , ( ) => {
811 const $store = { store : true }
912 const $route = { path : 'http://test.com' }
10- const wrapper = mount ( Component , {
13+ const wrapper = mountingMethod ( Component , {
1114 mocks : {
1215 $store,
1316 $route
@@ -20,7 +23,7 @@ describe('mount.mocks', () => {
2023 it ( 'adds variables to vm when passed as mocks object' , ( ) => {
2124 const stub = sinon . stub ( )
2225 const $reactiveMock = { value : 'value' }
23- const wrapper = mount ( {
26+ const wrapper = mountingMethod ( {
2427 template : `
2528 <div>
2629 {{value}}
@@ -45,23 +48,25 @@ describe('mount.mocks', () => {
4548 expect ( wrapper . text ( ) ) . to . contain ( 'changed value' )
4649 } )
4750
48- it ( 'adds variables available to nested vms' , ( ) => {
49- const count = 1
50- const wrapper = mount ( {
51- template : '<div><component-with-vuex /></div>' ,
52- components : {
53- ComponentWithVuex
54- }
55- } , {
56- mocks : { $store : { state : { count, foo : { } } } }
51+ itDoNotRunIf ( mountingMethod . name === 'shallow' ,
52+ 'adds variables available to nested vms' , ( ) => {
53+ const count = 1
54+ const wrapper = mountingMethod ( {
55+ template : '<div><component-with-vuex /></div>' ,
56+ components : {
57+ ComponentWithVuex
58+ }
59+ } , {
60+ mocks : { $store : { state : { count, foo : { } } } }
61+ } )
62+ expect ( wrapper . text ( ) ) . contains ( count )
5763 } )
58- expect ( wrapper . text ( ) ) . contains ( count )
59- } )
6064
61- it ( 'adds variables available to nested vms using localVue' , ( ) => {
65+ itDoNotRunIf ( mountingMethod . name === 'shallow' ,
66+ 'adds variables available to nested vms using localVue' , ( ) => {
6267 const localVue = createLocalVue ( )
6368 const count = 1
64- const wrapper = mount ( {
69+ const wrapper = mountingMethod ( {
6570 template : '<div><component-with-vuex /></div>' ,
6671 components : {
6772 ComponentWithVuex
@@ -75,13 +80,13 @@ describe('mount.mocks', () => {
7580
7681 it ( 'does not affect global vue class when passed as mocks object' , ( ) => {
7782 const $store = { store : true }
78- const wrapper = mount ( Component , {
83+ const wrapper = mountingMethod ( Component , {
7984 mocks : {
8085 $store
8186 }
8287 } )
8388 expect ( wrapper . vm . $store ) . to . equal ( $store )
84- const freshWrapper = mount ( Component )
89+ const freshWrapper = mountingMethod ( Component )
8590 expect ( typeof freshWrapper . vm . $store ) . to . equal ( 'undefined' )
8691 } )
8792
@@ -92,7 +97,7 @@ describe('mount.mocks', () => {
9297 value : 42
9398 } )
9499 const $store = 64
95- mount ( Component , {
100+ mountingMethod ( Component , {
96101 localVue,
97102 mocks : {
98103 $store
@@ -110,7 +115,7 @@ describe('mount.mocks', () => {
110115 value : 42
111116 } )
112117 const $val = 64
113- mount ( Component , {
118+ mountingMethod ( Component , {
114119 localVue,
115120 mocks : {
116121 $val
0 commit comments