summaryrefslogtreecommitdiff
path: root/spec/frontend/pipelines/pipeline_graph/gitlab_ci_yaml_visualization_spec.js
blob: fea423509598fa8d44447cc5ed01ea556b4a95fe (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
import { shallowMount } from '@vue/test-utils';
import { GlTab } from '@gitlab/ui';
import { yamlString } from './mock_data';
import PipelineGraph from '~/pipelines/components/pipeline_graph/pipeline_graph.vue';
import GitlabCiYamlVisualization from '~/pipelines/components/pipeline_graph/gitlab_ci_yaml_visualization.vue';

describe('gitlab yaml visualization component', () => {
  const defaultProps = { blobData: yamlString };
  let wrapper;

  const createComponent = props => {
    return shallowMount(GitlabCiYamlVisualization, {
      propsData: {
        ...defaultProps,
        ...props,
      },
    });
  };

  const findGlTabComponents = () => wrapper.findAll(GlTab);
  const findPipelineGraph = () => wrapper.find(PipelineGraph);

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

  describe('tabs component', () => {
    beforeEach(() => {
      wrapper = createComponent();
    });

    it('renders the file and visualization tabs', () => {
      expect(findGlTabComponents()).toHaveLength(2);
    });
  });

  describe('graph component', () => {
    beforeEach(() => {
      wrapper = createComponent();
    });

    it('is hidden by default', () => {
      expect(findPipelineGraph().exists()).toBe(false);
    });
  });
});