Welcome to mirror list, hosted at ThFree Co, Russian Federation.

pipeline_triggerer_spec.js « pipelines « javascripts « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 8cf290f2663f7fd47fc9ff20c3ae378a0c581ba8 (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
import { mount } from '@vue/test-utils';
import pipelineTriggerer from '~/pipelines/components/pipeline_triggerer.vue';

describe('Pipelines Triggerer', () => {
  let wrapper;

  const mockData = {
    pipeline: {
      user: {
        name: 'foo',
        avatar_url: '/avatar',
        path: '/path',
      },
    },
  };

  const createComponent = () => {
    wrapper = mount(pipelineTriggerer, {
      propsData: mockData,
    });
  };

  beforeEach(() => {
    createComponent();
  });

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

  it('should render a table cell', () => {
    expect(wrapper.contains('.table-section')).toBe(true);
  });

  it('should render triggerer information when triggerer is provided', () => {
    const link = wrapper.find('.js-pipeline-url-user');

    expect(link.attributes('href')).toEqual(mockData.pipeline.user.path);
    expect(link.find('.js-user-avatar-image-toolip').text()).toEqual(mockData.pipeline.user.name);
    expect(link.find('img.avatar').attributes('src')).toEqual(
      `${mockData.pipeline.user.avatar_url}?width=26`,
    );
  });

  it('should render "API" when no triggerer is provided', () => {
    wrapper.setProps({
      pipeline: {
        user: null,
      },
    });

    expect(wrapper.find('.js-pipeline-url-api').text()).toEqual('API');
  });
});