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

legacy_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: 7def4dd4f29abd37c55b7b8d89986372791f5ae4 (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
import { shallowMount } from '@vue/test-utils';
import Vue from 'vue';
import Vuex from 'vuex';
import LegacyCiVariableSettings from '~/ci_variable_list/components/legacy_ci_variable_settings.vue';
import createStore from '~/ci_variable_list/store';

Vue.use(Vuex);

describe('Ci variable table', () => {
  let wrapper;
  let store;
  let isProject;

  const createComponent = (projectState) => {
    store = createStore();
    store.state.isProject = projectState;
    jest.spyOn(store, 'dispatch').mockImplementation();
    wrapper = shallowMount(LegacyCiVariableSettings, {
      store,
    });
  };

  afterEach(() => {
    wrapper.destroy();
  });

  it('dispatches fetchEnvironments when mounted', () => {
    isProject = true;
    createComponent(isProject);
    expect(store.dispatch).toHaveBeenCalledWith('fetchEnvironments');
  });

  it('does not dispatch fetchenvironments when in group context', () => {
    isProject = false;
    createComponent(isProject);
    expect(store.dispatch).not.toHaveBeenCalled();
  });
});