summaryrefslogtreecommitdiff
path: root/spec/frontend/commit/commit_box_pipeline_mini_graph_spec.js
blob: 1a2e188e7ae636e0f1454df21e4b8612d87c8a9d (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
import { shallowMount } from '@vue/test-utils';
import { extendedWrapper } from 'helpers/vue_test_utils_helper';
import CommitBoxPipelineMiniGraph from '~/projects/commit_box/info/components/commit_box_pipeline_mini_graph.vue';
import { mockStages } from './mock_data';

describe('Commit box pipeline mini graph', () => {
  let wrapper;

  const findMiniGraph = () => wrapper.findByTestId('commit-box-mini-graph');
  const findUpstream = () => wrapper.findByTestId('commit-box-mini-graph-upstream');
  const findDownstream = () => wrapper.findByTestId('commit-box-mini-graph-downstream');

  const createComponent = () => {
    wrapper = extendedWrapper(
      shallowMount(CommitBoxPipelineMiniGraph, {
        propsData: {
          stages: mockStages,
        },
        mocks: {
          $apollo: {
            queries: {
              pipeline: {
                loading: false,
              },
            },
          },
        },
      }),
    );
  };

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

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

  describe('linked pipelines', () => {
    it('should display the mini pipeine graph', () => {
      expect(findMiniGraph().exists()).toBe(true);
    });

    it('should not display linked pipelines', () => {
      expect(findUpstream().exists()).toBe(false);
      expect(findDownstream().exists()).toBe(false);
    });
  });
});