39 lines
998 B
JavaScript
39 lines
998 B
JavaScript
import { shallowMount } from '@vue/test-utils';
|
|
import Vue from 'vue';
|
|
import Vuex from 'vuex';
|
|
import CiVariableSettings from '~/ci_variable_list/components/ci_variable_settings.vue';
|
|
import createStore from '~/ci_variable_list/store';
|
|
|
|
Vue.use(Vuex);
|
|
|
|
describe('Ci variable table', () => {
|
|
let wrapper;
|
|
let store;
|
|
let isGroup;
|
|
|
|
const createComponent = (groupState) => {
|
|
store = createStore();
|
|
store.state.isGroup = groupState;
|
|
jest.spyOn(store, 'dispatch').mockImplementation();
|
|
wrapper = shallowMount(CiVariableSettings, {
|
|
store,
|
|
});
|
|
};
|
|
|
|
afterEach(() => {
|
|
wrapper.destroy();
|
|
});
|
|
|
|
it('dispatches fetchEnvironments when mounted', () => {
|
|
isGroup = false;
|
|
createComponent(isGroup);
|
|
expect(store.dispatch).toHaveBeenCalledWith('fetchEnvironments');
|
|
});
|
|
|
|
it('does not dispatch fetchenvironments when in group context', () => {
|
|
isGroup = true;
|
|
createComponent(isGroup);
|
|
expect(store.dispatch).not.toHaveBeenCalled();
|
|
});
|
|
});
|