debian-mirror-gitlab/spec/frontend/issues/show/components/fields/title_spec.js
2022-06-21 17:19:12 +05:30

40 lines
1,006 B
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: {
value: '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');
});
});