debian-mirror-gitlab/spec/frontend/issues/show/components/fields/title_spec.js
2022-01-26 12:08:38 +05:30

42 lines
1 KiB
JavaScript

import { shallowMount } from '@vue/test-utils';
import TitleField from '~/issues/show/components/fields/title.vue';
import eventHub from '~/issues/show/event_hub';
describe('Title field component', () => {
let wrapper;
const findInput = () => wrapper.find({ ref: 'input' });
beforeEach(() => {
jest.spyOn(eventHub, '$emit');
wrapper = shallowMount(TitleField, {
propsData: {
formState: {
title: 'test',
},
},
});
});
afterEach(() => {
wrapper.destroy();
wrapper = null;
});
it('renders form control with formState title', () => {
expect(findInput().element.value).toBe('test');
});
it('triggers update with meta+enter', () => {
findInput().trigger('keydown.enter', { metaKey: true });
expect(eventHub.$emit).toHaveBeenCalledWith('update.issuable');
});
it('triggers update with ctrl+enter', () => {
findInput().trigger('keydown.enter', { ctrlKey: true });
expect(eventHub.$emit).toHaveBeenCalledWith('update.issuable');
});
});