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

mr_widget_missing_branch_spec.js « states « components « vue_mr_widget « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: f45368bf4432c261cd8baa536461d47840834e1c (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
import { shallowMount } from '@vue/test-utils';
import MissingBranchComponent from '~/vue_merge_request_widget/components/states/mr_widget_missing_branch.vue';

let wrapper;

function factory(sourceBranchRemoved, mergeRequestWidgetGraphql) {
  wrapper = shallowMount(MissingBranchComponent, {
    propsData: {
      mr: { sourceBranchRemoved },
    },
    provide: {
      glFeatures: { mergeRequestWidgetGraphql },
    },
  });

  if (mergeRequestWidgetGraphql) {
    wrapper.setData({ state: { sourceBranchExists: !sourceBranchRemoved } });
  }

  return wrapper.vm.$nextTick();
}

describe('MRWidgetMissingBranch', () => {
  afterEach(() => {
    wrapper.destroy();
  });

  [true, false].forEach(mergeRequestWidgetGraphql => {
    describe(`widget GraphQL feature flag is ${
      mergeRequestWidgetGraphql ? 'enabled' : 'disabled'
    }`, () => {
      it.each`
        sourceBranchRemoved | branchName
        ${true}             | ${'source'}
        ${false}            | ${'target'}
      `(
        'should set missing branch name as $branchName when sourceBranchRemoved is $sourceBranchRemoved',
        async ({ sourceBranchRemoved, branchName }) => {
          await factory(sourceBranchRemoved, mergeRequestWidgetGraphql);

          expect(wrapper.find('[data-testid="missingBranchName"]').text()).toContain(branchName);
        },
      );
    });
  });
});