debian-mirror-gitlab/spec/frontend/ci_variable_list/components/ci_variable_settings_spec.js

40 lines
1 KiB
JavaScript
Raw Normal View History

2020-04-08 14:13:33 +05:30
import { createLocalVue, shallowMount } from '@vue/test-utils';
2021-03-11 19:13:27 +05:30
import Vuex from 'vuex';
2020-04-08 14:13:33 +05:30
import CiVariableSettings from '~/ci_variable_list/components/ci_variable_settings.vue';
import createStore from '~/ci_variable_list/store';
const localVue = createLocalVue();
localVue.use(Vuex);
describe('Ci variable table', () => {
let wrapper;
let store;
let isGroup;
2021-03-08 18:12:59 +05:30
const createComponent = (groupState) => {
2020-04-08 14:13:33 +05:30
store = createStore();
store.state.isGroup = groupState;
jest.spyOn(store, 'dispatch').mockImplementation();
wrapper = shallowMount(CiVariableSettings, {
localVue,
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();
});
});