debian-mirror-gitlab/spec/frontend/issue_show/components/fields/title_spec.js

43 lines
1 KiB
JavaScript
Raw Normal View History

2021-03-11 19:13:27 +05:30
import { shallowMount } from '@vue/test-utils';
import TitleField from '~/issue_show/components/fields/title.vue';
2017-09-10 17:25:29 +05:30
import eventHub from '~/issue_show/event_hub';
describe('Title field component', () => {
2021-03-11 19:13:27 +05:30
let wrapper;
2017-09-10 17:25:29 +05:30
2021-03-11 19:13:27 +05:30
const findInput = () => wrapper.find({ 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: {
2021-03-11 19:13:27 +05:30
formState: {
title: 'test',
},
2017-09-10 17:25:29 +05:30
},
2021-03-11 19:13:27 +05:30
});
});
afterEach(() => {
wrapper.destroy();
wrapper = null;
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
});