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

take_ownership_modal_spec.js « components « pipeline_schedules « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: d787611fe8f0e39157430ebe3a08f19030056a74 (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
52
53
54
import { GlModal } from '@gitlab/ui';
import { shallowMountExtended } from 'helpers/vue_test_utils_helper';
import TakeOwnershipModal from '~/pipeline_schedules/components/take_ownership_modal.vue';

describe('Take ownership modal', () => {
  let wrapper;
  const url = `/root/job-log-tester/-/pipeline_schedules/3/take_ownership`;

  const createComponent = (props = {}) => {
    wrapper = shallowMountExtended(TakeOwnershipModal, {
      propsData: {
        ownershipUrl: url,
        ...props,
      },
    });
  };

  const findModal = () => wrapper.findComponent(GlModal);

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

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

  it('has a primary action set to a url and a post data-method', () => {
    const actionPrimary = findModal().props('actionPrimary');

    expect(actionPrimary.attributes).toEqual(
      expect.objectContaining([
        {
          category: 'primary',
          variant: 'confirm',
          href: url,
          'data-method': 'post',
        },
      ]),
    );
  });

  it('shows a take ownership message', () => {
    expect(findModal().text()).toBe(
      'Only the owner of a pipeline schedule can make changes to it. Do you want to take ownership of this schedule?',
    );
  });

  it('emits the cancel event when clicking on cancel', async () => {
    findModal().vm.$emit('cancel');

    expect(findModal().emitted('cancel')).toHaveLength(1);
  });
});