Commit c63857e3 authored by Illya Klymov's avatar Illya Klymov

Make vuex-module-provider do not blow up when used with vue-apollo

- upstream issue: https://github.com/vuejs/vue-apollo/pull/1153
parent 679cf33e
......@@ -2,7 +2,10 @@
export default {
provide() {
return {
vuexModule: this.vuexModule,
// We can't use this.vuexModule due to bug in vue-apollo when
// provide is called in beforeCreate
// See https://github.com/vuejs/vue-apollo/pull/1153 for details
vuexModule: this.$options.propsData.vuexModule,
};
},
props: {
......
import { mount } from '@vue/test-utils';
import { mount, createLocalVue } from '@vue/test-utils';
import Vue from 'vue';
import VueApollo from 'vue-apollo';
import VuexModuleProvider from '~/vue_shared/components/vuex_module_provider.vue';
const TestComponent = Vue.extend({
......@@ -14,7 +15,7 @@ describe('~/vue_shared/components/vuex_module_provider', () => {
const findProvidedVuexModule = () => wrapper.find('[data-testid="vuexModule"]').text();
beforeEach(() => {
const createComponent = (extraParams = {}) => {
wrapper = mount(VuexModuleProvider, {
propsData: {
vuexModule: TEST_VUEX_MODULE,
......@@ -22,10 +23,25 @@ describe('~/vue_shared/components/vuex_module_provider', () => {
slots: {
default: TestComponent,
},
...extraParams,
});
};
afterEach(() => {
wrapper.destroy();
});
it('provides "vuexModule" set from prop', () => {
createComponent();
expect(findProvidedVuexModule()).toBe(TEST_VUEX_MODULE);
});
it('does not blow up when used with vue-apollo', () => {
// See https://github.com/vuejs/vue-apollo/pull/1153 for details
const localVue = createLocalVue();
localVue.use(VueApollo);
createComponent({ localVue });
expect(findProvidedVuexModule()).toBe(TEST_VUEX_MODULE);
});
});
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment