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

confirmation_modal_spec.js « components « edit « integrations « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 805d3971994c2a7ea3f2d6d54124f40e05573485 (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
import { GlModal } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils';

import ConfirmationModal from '~/integrations/edit/components/confirmation_modal.vue';
import { createStore } from '~/integrations/edit/store';

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

  const createComponent = () => {
    wrapper = shallowMount(ConfirmationModal, {
      store: createStore(),
    });
  };

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

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

  describe('template', () => {
    beforeEach(() => {
      createComponent();
    });

    it('renders GlModal with correct copy', () => {
      expect(findGlModal().exists()).toBe(true);
      expect(findGlModal().attributes('title')).toBe('Save settings?');
      expect(findGlModal().text()).toContain(
        'Saving will update the default settings for all projects that are not using custom settings.',
      );
      expect(findGlModal().text()).toContain(
        'Projects using custom settings will not be impacted unless the project owner chooses to use parent level defaults.',
      );
    });

    it('emits `submit` event when `primary` event is emitted on GlModal', async () => {
      expect(wrapper.emitted().submit).toBeUndefined();

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

      await wrapper.vm.$nextTick();

      expect(wrapper.emitted().submit).toHaveLength(1);
    });
  });
});