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

advanced_settings_spec.js « components « import_projects « import_entities « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 68716600592d6cd334680271f0636f80c562ac4e (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
54
55
56
57
58
59
60
import { mount } from '@vue/test-utils';
import { GlFormCheckbox } from '@gitlab/ui';
import AdvancedSettingsPanel from '~/import_entities/import_projects/components/advanced_settings.vue';

describe('Import Advanced Settings', () => {
  let wrapper;
  const OPTIONAL_STAGES = [
    { name: 'stage1', label: 'Stage 1' },
    { name: 'stage2', label: 'Stage 2', details: 'Extra details' },
  ];

  const createComponent = () => {
    wrapper = mount(AdvancedSettingsPanel, {
      propsData: {
        stages: OPTIONAL_STAGES,
        value: {
          stage1: false,
          stage2: false,
        },
      },
    });
  };

  beforeEach(() => {
    createComponent();
  });

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

  it('renders GLFormCheckbox for each optional stage', () => {
    expect(wrapper.findAllComponents(GlFormCheckbox)).toHaveLength(OPTIONAL_STAGES.length);
  });

  it('renders label for each optional stage', () => {
    wrapper.findAllComponents(GlFormCheckbox).wrappers.forEach((w, idx) => {
      expect(w.text()).toContain(OPTIONAL_STAGES[idx].label);
    });
  });

  it('renders details for stage with details', () => {
    expect(wrapper.findAllComponents(GlFormCheckbox).at(1).text()).toContain(
      OPTIONAL_STAGES[1].details,
    );
  });

  it('emits new stages selection state when checkbox is changed', () => {
    const firstCheckbox = wrapper.findComponent(GlFormCheckbox);

    firstCheckbox.vm.$emit('change', true);

    expect(wrapper.emitted('input')[0]).toStrictEqual([
      {
        stage1: true,
        stage2: false,
      },
    ]);
  });
});