Welcome to mirror list, hosted at ThFree Co, Russian Federation.

ci_variable_settings_spec.js « components « ci_variable_list « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 12449fc761594710f56694cdc41cd53fc2f16165 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import Vuex from 'vuex';
import { createLocalVue, shallowMount } from '@vue/test-utils';
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;

  const createComponent = (groupState) => {
    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();
  });
});