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

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

41 lines
1,006 B
JavaScript
Raw Normal View History

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
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: {
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
});
});
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
});