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

candidate_detail_row_spec.js « components « show « candidates « routes « experiment_tracking « ml « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 53dbd796d85142b858057bb923dac0ea597a6774 (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 } from '@vue/test-utils';
import DetailRow from '~/ml/experiment_tracking/routes/candidates/show/components/candidate_detail_row.vue';

describe('CandidateDetailRow', () => {
  const SECTION_LABEL_CELL = 0;
  const ROW_LABEL_CELL = 1;
  const ROW_VALUE_CELL = 2;

  let wrapper;

  const createWrapper = ({ slots = {} } = {}) => {
    wrapper = shallowMount(DetailRow, {
      propsData: { sectionLabel: 'Section', label: 'Item' },
      slots,
    });
  };

  const findCellAt = (index) => wrapper.findAll('td').at(index);

  beforeEach(() => createWrapper());

  it('renders section label', () => {
    expect(findCellAt(SECTION_LABEL_CELL).text()).toBe('Section');
  });

  it('renders row label', () => {
    expect(findCellAt(ROW_LABEL_CELL).text()).toBe('Item');
  });

  it('renders nothing on item cell', () => {
    expect(findCellAt(ROW_VALUE_CELL).text()).toBe('');
  });

  describe('With slot', () => {
    beforeEach(() => createWrapper({ slots: { default: 'Some content' } }));

    it('Renders slot', () => {
      expect(findCellAt(ROW_VALUE_CELL).text()).toBe('Some content');
    });
  });
});