summaryrefslogtreecommitdiff
path: root/spec/javascripts/pipelines/graph/action_component_spec.js
blob: f033956c0715b92e308528bbe7d154922228948d (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
import Vue from 'vue';
import actionComponent from '~/pipelines/components/graph/action_component.vue';

describe('pipeline graph action component', () => {
  let component;

  beforeEach(() => {
    const ActionComponent = Vue.extend(actionComponent);
    component = new ActionComponent({
      propsData: {
        tooltipText: 'bar',
        link: 'foo',
        actionMethod: 'post',
        actionIcon: 'icon_action_cancel',
      },
    }).$mount();
  });

  it('should render a link', () => {
    expect(component.$el.getAttribute('href')).toEqual('foo');
  });

  it('should render the provided title as a bootstrap tooltip', () => {
    expect(component.$el.getAttribute('data-original-title')).toEqual('bar');
  });

  it('should update bootstrap tooltip when title changes', (done) => {
    component.tooltipText = 'changed';

    Vue.nextTick(() => {
      expect(component.$el.getAttribute('data-original-title')).toBe('changed');
      done();
    });
  });

  it('should render an svg', () => {
    expect(component.$el.querySelector('.ci-action-icon-wrapper')).toBeDefined();
    expect(component.$el.querySelector('svg')).toBeDefined();
  });
});