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

runner_edit_button_spec.js « components « runner « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 428c1ef07e97fbf06ec6327a3001131b36fdbecf (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
import { shallowMount, mount } from '@vue/test-utils';
import RunnerEditButton from '~/runner/components/runner_edit_button.vue';
import { createMockDirective, getBinding } from 'helpers/vue_mock_directive';

describe('RunnerEditButton', () => {
  let wrapper;

  const getTooltipValue = () => getBinding(wrapper.element, 'gl-tooltip').value;

  const createComponent = ({ attrs = {}, mountFn = shallowMount } = {}) => {
    wrapper = mountFn(RunnerEditButton, {
      attrs,
      directives: {
        GlTooltip: createMockDirective(),
      },
    });
  };

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

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

  it('Displays Edit text', () => {
    expect(wrapper.attributes('aria-label')).toBe('Edit');
  });

  it('Displays Edit tooltip', () => {
    expect(getTooltipValue()).toBe('Edit');
  });

  it('Renders a link and adds an href attribute', () => {
    createComponent({ attrs: { href: '/edit' }, mountFn: mount });

    expect(wrapper.element.tagName).toBe('A');
    expect(wrapper.attributes('href')).toBe('/edit');
  });
});