summaryrefslogtreecommitdiff
path: root/spec/javascripts/pipelines/navigation_tabs_spec.js
blob: f125a2fa1892eeb57a2f753f172fd24f21870cd3 (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
import Vue from 'vue';
import navigationTabs from '~/pipelines/components/navigation_tabs.vue';
import mountComponent from '../helpers/vue_mount_component_helper';

describe('navigation tabs pipeline component', () => {
  let vm;
  let Component;
  let data;

  beforeEach(() => {
    data = [
      {
        name: 'All',
        scope: 'all',
        count: 1,
        isActive: true,
      },
      {
        name: 'Pending',
        scope: 'pending',
        count: 0,
        isActive: false,
      },
      {
        name: 'Running',
        scope: 'running',
        isActive: false,
      },
    ];

    Component = Vue.extend(navigationTabs);
    vm = mountComponent(Component, { tabs: data });
  });

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

  it('should render tabs', () => {
    expect(vm.$el.querySelectorAll('li').length).toEqual(data.length);
  });

  it('should render active tab', () => {
    expect(vm.$el.querySelector('.active .js-pipelines-tab-all')).toBeDefined();
  });

  it('should render badge', () => {
    expect(vm.$el.querySelector('.js-pipelines-tab-all .badge').textContent.trim()).toEqual('1');
    expect(vm.$el.querySelector('.js-pipelines-tab-pending .badge').textContent.trim()).toEqual('0');
  });

  it('should not render badge', () => {
    expect(vm.$el.querySelector('.js-pipelines-tab-running .badge')).toEqual(null);
  });
});