summaryrefslogtreecommitdiff
path: root/spec/javascripts/jobs/components/stages_dropdown_spec.js
blob: fcff78b943e1a68c6fdf30df8a8c35dacc4219a0 (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
import Vue from 'vue';
import component from '~/jobs/components/stages_dropdown.vue';
import mountComponent from '../../helpers/vue_mount_component_helper';

describe('Stages Dropdown', () => {
  const Component = Vue.extend(component);
  let vm;

  beforeEach(() => {
    vm = mountComponent(Component, {
      pipeline: {
        id: 28029444,
        details: {
          status: {
            details_path: '/gitlab-org/gitlab-ce/pipelines/28029444',
            group: 'success',
            has_details: true,
            icon: 'status_success',
            label: 'passed',
            text: 'passed',
            tooltip: 'passed',
          },
        },
        path: 'pipeline/28029444',
      },
      stages: [
        {
          name: 'build',
        },
        {
          name: 'test',
        },
      ],
      selectedStage: 'deploy'
    });
  });

  afterEach(() => {
    vm.$destroy();
  });

  it('renders pipeline status', () => {
    expect(vm.$el.querySelector('.js-ci-status-icon-success')).not.toBeNull();
  });

  it('renders pipeline link', () => {
    expect(vm.$el.querySelector('.js-pipeline-path').getAttribute('href')).toEqual(
      'pipeline/28029444',
    );
  });

  it('renders dropdown with stages', () => {
    expect(vm.$el.querySelector('.dropdown .js-stage-item').textContent).toContain('build');
  });

  it('rendes selected stage', () => {
    expect(vm.$el.querySelector('.dropdown .js-selected-stage').textContent).toContain('deploy');
  });
});