summaryrefslogtreecommitdiff
path: root/spec/frontend/runner/components/cells/runner_name_cell_spec.js
blob: 26055fc0fafcd558115b3902aa59a5963a61594d (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
import { GlLink } from '@gitlab/ui';
import { mount } from '@vue/test-utils';
import RunnerNameCell from '~/runner/components/cells/runner_name_cell.vue';

const mockId = '1';
const mockShortSha = '2P6oDVDm';
const mockDescription = 'runner-1';

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

  const findLink = () => wrapper.findComponent(GlLink);

  const createComponent = () => {
    wrapper = mount(RunnerNameCell, {
      propsData: {
        runner: {
          id: `gid://gitlab/Ci::Runner/${mockId}`,
          shortSha: mockShortSha,
          description: mockDescription,
        },
      },
    });
  };

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

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

  it('Displays the runner link with id and short token', () => {
    expect(findLink().text()).toBe(`#${mockId} (${mockShortSha})`);
    expect(findLink().attributes('href')).toBe(`/admin/runners/${mockId}`);
  });

  it('Displays the runner description', () => {
    expect(wrapper.text()).toContain(mockDescription);
  });
});