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

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

import { eventHub } from '~/vue_shared/components/recaptcha_eventhub';

import RecaptchaModal from '~/vue_shared/components/recaptcha_modal.vue';

describe('RecaptchaModal', () => {
  const recaptchaFormId = 'recaptcha-form';
  const recaptchaHtml = `<form id="${recaptchaFormId}"></form>`;

  let wrapper;

  const findRecaptchaForm = () => wrapper.find(`#${recaptchaFormId}`).element;

  beforeEach(() => {
    wrapper = shallowMount(RecaptchaModal, {
      propsData: {
        html: recaptchaHtml,
      },
    });
  });

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

  it('submits the form if event hub emits submit event', () => {
    const form = findRecaptchaForm();
    jest.spyOn(form, 'submit').mockImplementation();

    eventHub.$emit('submit');

    expect(form.submit).toHaveBeenCalled();
  });
});