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

runner_delete_modal_spec.js « components « runner « ci « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: f2fb02067630077aeba189962eb989b1bf101bf7 (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
55
56
57
58
59
60
import { GlModal } from '@gitlab/ui';
import { mount, shallowMount } from '@vue/test-utils';
import RunnerDeleteModal from '~/ci/runner/components/runner_delete_modal.vue';

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

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

  const createComponent = ({ props = {} } = {}, mountFn = shallowMount) => {
    wrapper = mountFn(RunnerDeleteModal, {
      attachTo: document.body,
      propsData: {
        runnerName: '#99 (AABBCCDD)',
        ...props,
      },
      attrs: {
        modalId: 'delete-runner-modal-99',
      },
    });
  };

  it('Displays title', () => {
    createComponent();

    expect(findGlModal().props('title')).toBe('Delete runner #99 (AABBCCDD)?');
  });

  it('Displays buttons', () => {
    createComponent();

    expect(findGlModal().props('actionPrimary')).toMatchObject({ text: 'Delete runner' });
    expect(findGlModal().props('actionCancel')).toMatchObject({ text: 'Cancel' });
  });

  it('Displays contents', () => {
    createComponent();

    expect(findGlModal().html()).toContain(
      'The runner will be permanently deleted and no longer available for projects or groups in the instance. Are you sure you want to continue?',
    );
  });

  describe('When modal is confirmed by the user', () => {
    let hideModalSpy;

    beforeEach(() => {
      createComponent({}, mount);
      hideModalSpy = jest.spyOn(wrapper.vm.$refs.modal, 'hide').mockImplementation(() => {});
    });

    it('Modal gets hidden', () => {
      expect(hideModalSpy).toHaveBeenCalledTimes(0);

      findGlModal().vm.$emit('primary');

      expect(hideModalSpy).toHaveBeenCalledTimes(1);
    });
  });
});