|
1 | 1 | import mount from '~src/mount'
|
| 2 | +import createLocalVue from '~src/create-local-vue' |
2 | 3 | import Component from '~resources/components/component.vue'
|
| 4 | +import ComponentWithVuex from '~resources/components/component-with-vuex.vue' |
3 | 5 |
|
4 | 6 | describe('mount.mocks', () => {
|
5 | 7 | it('adds variables to vm when passed as mocks object', () => {
|
@@ -43,6 +45,34 @@ describe('mount.mocks', () => {
|
43 | 45 | expect(wrapper.text()).to.contain('changed value')
|
44 | 46 | })
|
45 | 47 |
|
| 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: {}}}} |
| 57 | + }) |
| 58 | + expect(wrapper.text()).contains(count) |
| 59 | + }) |
| 60 | + |
| 61 | + it('adds variables available to nested vms using localVue', () => { |
| 62 | + const localVue = createLocalVue() |
| 63 | + const count = 1 |
| 64 | + const wrapper = mount({ |
| 65 | + template: '<div><component-with-vuex /></div>', |
| 66 | + components: { |
| 67 | + ComponentWithVuex |
| 68 | + } |
| 69 | + }, { |
| 70 | + mocks: { $store: { state: { count, foo: {}}}}, |
| 71 | + localVue |
| 72 | + }) |
| 73 | + expect(wrapper.text()).contains(count) |
| 74 | + }) |
| 75 | + |
46 | 76 | it('does not affect global vue class when passed as mocks object', () => {
|
47 | 77 | const $store = { store: true }
|
48 | 78 | const wrapper = mount(Component, {
|
|
0 commit comments