summaryrefslogtreecommitdiff
path: root/spec/javascripts/jobs/components/sidebar_detail_row_spec.js
blob: 42d11266daddb639a66fb4289b5ab2f8bfb1529a (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
60
61
import Vue from 'vue';
import sidebarDetailRow from '~/jobs/components/sidebar_detail_row.vue';

describe('Sidebar detail row', () => {
  let SidebarDetailRow;
  let vm;

  beforeEach(() => {
    SidebarDetailRow = Vue.extend(sidebarDetailRow);
  });

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

  it('should render no title', () => {
    vm = new SidebarDetailRow({
      propsData: {
        value: 'this is the value',
      },
    }).$mount();

    expect(vm.$el.textContent.replace(/\s+/g, ' ').trim()).toEqual('this is the value');
  });

  beforeEach(() => {
    vm = new SidebarDetailRow({
      propsData: {
        title: 'this is the title',
        value: 'this is the value',
      },
    }).$mount();
  });

  it('should render provided title and value', () => {
    expect(vm.$el.textContent.replace(/\s+/g, ' ').trim()).toEqual(
      'this is the title: this is the value',
    );
  });

  describe('when helpUrl not provided', () => {
    it('should not render help', () => {
      expect(vm.$el.querySelector('.help-button')).toBeNull();
    });
  });

  describe('when helpUrl provided', () => {
    beforeEach(() => {
      vm = new SidebarDetailRow({
        propsData: {
          helpUrl: 'help url',
          value: 'foo',
        },
      }).$mount();
    });

    it('should render help', () => {
      expect(vm.$el.querySelector('.help-button a').getAttribute('href')).toEqual('help url');
    });
  });
});