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

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

import SubmitChangesError from '~/static_site_editor/components/submit_changes_error.vue';

import { submitChangesError as error } from '../mock_data';

describe('Submit Changes Error', () => {
  let wrapper;

  const buildWrapper = (propsData = {}) => {
    wrapper = shallowMount(SubmitChangesError, {
      propsData: {
        ...propsData,
      },
      stubs: {
        GlAlert,
      },
    });
  };

  const findRetryButton = () => wrapper.find(GlButton);
  const findAlert = () => wrapper.find(GlAlert);

  beforeEach(() => {
    buildWrapper({ error });
  });

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

  it('renders error message', () => {
    expect(findAlert().text()).toContain(error);
  });

  it('emits dismiss event when alert emits dismiss event', () => {
    findAlert().vm.$emit('dismiss');

    expect(wrapper.emitted('dismiss')).toHaveLength(1);
  });

  it('emits retry event when retry button is clicked', () => {
    findRetryButton().vm.$emit('click');

    expect(wrapper.emitted('retry')).toHaveLength(1);
  });
});