debian-mirror-gitlab/spec/frontend/vue_shared/components/recaptcha_modal_spec.js

36 lines
867 B
JavaScript
Raw Normal View History

2019-12-21 20:55:43 +05:30
import { shallowMount } from '@vue/test-utils';
import { eventHub } from '~/vue_shared/components/recaptcha_eventhub';
2020-03-09 13:42:32 +05:30
import RecaptchaModal from '~/vue_shared/components/recaptcha_modal.vue';
2019-12-21 20:55:43 +05:30
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();
});
});