summaryrefslogtreecommitdiff
path: root/spec/frontend/ci/pipeline_schedules/components/table/cells/pipeline_schedule_last_pipeline_spec.js
blob: 0821c59c8a0198e479e279dad43f2d8a643394e3 (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
import { shallowMountExtended } from 'helpers/vue_test_utils_helper';
import CiBadgeLink from '~/vue_shared/components/ci_badge_link.vue';
import PipelineScheduleLastPipeline from '~/ci/pipeline_schedules/components/table/cells/pipeline_schedule_last_pipeline.vue';
import { mockPipelineScheduleNodes } from '../../../mock_data';

describe('Pipeline schedule last pipeline', () => {
  let wrapper;

  const defaultProps = {
    schedule: mockPipelineScheduleNodes[2],
  };

  const createComponent = (props = defaultProps) => {
    wrapper = shallowMountExtended(PipelineScheduleLastPipeline, {
      propsData: {
        ...props,
      },
    });
  };

  const findCIBadgeLink = () => wrapper.findComponent(CiBadgeLink);
  const findStatusText = () => wrapper.findByTestId('pipeline-schedule-status-text');

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

  it('displays pipeline status', () => {
    createComponent();

    expect(findCIBadgeLink().exists()).toBe(true);
    expect(findCIBadgeLink().props('status')).toBe(
      defaultProps.schedule.lastPipeline.detailedStatus,
    );
    expect(findStatusText().exists()).toBe(false);
  });

  it('displays "none" status text', () => {
    createComponent({ schedule: mockPipelineScheduleNodes[0] });

    expect(findStatusText().text()).toBe('None');
    expect(findCIBadgeLink().exists()).toBe(false);
  });
});