Commit 140a220f authored by Natalia Tepluhina's avatar Natalia Tepluhina

Merge branch 'xanf-fix-vuex-module-provider' into 'master'

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

See merge request gitlab-org/gitlab!61090
parents 9f36d40d c63857e3
......@@ -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