summaryrefslogtreecommitdiff
path: root/spec/frontend/runner/components/cells/runner_summary_cell_spec.js
blob: 1c9282e0acdc961948508c1f50309346587cc144 (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
import { mount } from '@vue/test-utils';
import RunnerSummaryCell from '~/runner/components/cells/runner_summary_cell.vue';

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

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

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

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

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

  it('Displays the runner name as id and short token', () => {
    expect(wrapper.text()).toContain(`#${mockId} (${mockShortSha})`);
  });

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

  it('Displays a custom slot', () => {
    const slotContent = 'My custom runner summary';

    createComponent({
      slots: {
        'runner-name': slotContent,
      },
    });

    expect(wrapper.text()).toContain(slotContent);
  });
});