2021-03-11 19:13:27 +05:30
|
|
|
import { shallowMount } from '@vue/test-utils';
|
2022-01-26 12:08:38 +05:30
|
|
|
import TitleField from '~/issues/show/components/fields/title.vue';
|
|
|
|
import eventHub from '~/issues/show/event_hub';
|
2017-09-10 17:25:29 +05:30
|
|
|
|
|
|
|
describe('Title field component', () => {
|
2021-03-11 19:13:27 +05:30
|
|
|
let wrapper;
|
2017-09-10 17:25:29 +05:30
|
|
|
|
2022-10-11 01:57:18 +05:30
|
|
|
const findInput = () => wrapper.findComponent({ ref: 'input' });
|
2017-09-10 17:25:29 +05:30
|
|
|
|
2021-03-11 19:13:27 +05:30
|
|
|
beforeEach(() => {
|
|
|
|
jest.spyOn(eventHub, '$emit');
|
2017-09-10 17:25:29 +05:30
|
|
|
|
2021-03-11 19:13:27 +05:30
|
|
|
wrapper = shallowMount(TitleField, {
|
2017-09-10 17:25:29 +05:30
|
|
|
propsData: {
|
2022-06-21 17:19:12 +05:30
|
|
|
value: 'test',
|
2017-09-10 17:25:29 +05:30
|
|
|
},
|
2021-03-11 19:13:27 +05:30
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
it('renders form control with formState title', () => {
|
2021-03-11 19:13:27 +05:30
|
|
|
expect(findInput().element.value).toBe('test');
|
2017-09-10 17:25:29 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
it('triggers update with meta+enter', () => {
|
2021-03-11 19:13:27 +05:30
|
|
|
findInput().trigger('keydown.enter', { metaKey: true });
|
2017-09-10 17:25:29 +05:30
|
|
|
|
2021-03-11 19:13:27 +05:30
|
|
|
expect(eventHub.$emit).toHaveBeenCalledWith('update.issuable');
|
2017-09-10 17:25:29 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
it('triggers update with ctrl+enter', () => {
|
2021-03-11 19:13:27 +05:30
|
|
|
findInput().trigger('keydown.enter', { ctrlKey: true });
|
2019-07-31 22:56:46 +05:30
|
|
|
|
2021-03-11 19:13:27 +05:30
|
|
|
expect(eventHub.$emit).toHaveBeenCalledWith('update.issuable');
|
2019-07-31 22:56:46 +05:30
|
|
|
});
|
2017-09-10 17:25:29 +05:30
|
|
|
});
|