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

gke_submit_button_spec.js « components « gke_cluster « create_cluster « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 014ed6013bde6b5b35c327473502c54fc6da76b5 (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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import { shallowMount, createLocalVue } from '@vue/test-utils';
import Vuex from 'vuex';
import GkeSubmitButton from '~/create_cluster/gke_cluster/components/gke_submit_button.vue';

const localVue = createLocalVue();

localVue.use(Vuex);

describe('GkeSubmitButton', () => {
  let wrapper;
  let store;
  let hasValidData;

  const buildStore = () =>
    new Vuex.Store({
      getters: {
        hasValidData,
      },
    });

  const buildWrapper = () =>
    shallowMount(GkeSubmitButton, {
      store,
      localVue,
    });

  const bootstrap = () => {
    store = buildStore();
    wrapper = buildWrapper();
  };

  beforeEach(() => {
    hasValidData = jest.fn();
  });

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

  it('is disabled when hasValidData is false', () => {
    hasValidData.mockReturnValueOnce(false);
    bootstrap();

    expect(wrapper.attributes('disabled')).toBe('disabled');
  });

  it('is not disabled when hasValidData is true', () => {
    hasValidData.mockReturnValueOnce(true);
    bootstrap();

    expect(wrapper.attributes('disabled')).toBeFalsy();
  });
});