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

49 lines
1.2 KiB
JavaScript
Raw Normal View History

2017-09-10 17:25:29 +05:30
import Vue from 'vue';
import eventHub from '~/issue_show/event_hub';
import Store from '~/issue_show/stores';
import titleField from '~/issue_show/components/fields/title.vue';
import { keyboardDownEvent } from '../../helpers';
describe('Title field component', () => {
let vm;
let store;
beforeEach(() => {
const Component = Vue.extend(titleField);
store = new Store({
titleHtml: '',
descriptionHtml: '',
issuableRef: '',
});
store.formState.title = 'test';
spyOn(eventHub, '$emit');
vm = new Component({
propsData: {
formState: store.formState,
},
}).$mount();
});
it('renders form control with formState title', () => {
2018-12-13 13:39:08 +05:30
expect(vm.$el.querySelector('.form-control').value).toBe('test');
2017-09-10 17:25:29 +05:30
});
it('triggers update with meta+enter', () => {
vm.$el.querySelector('.form-control').dispatchEvent(keyboardDownEvent(13, true));
2018-12-13 13:39:08 +05:30
expect(eventHub.$emit).toHaveBeenCalled();
2017-09-10 17:25:29 +05:30
});
it('triggers update with ctrl+enter', () => {
vm.$el.querySelector('.form-control').dispatchEvent(keyboardDownEvent(13, false, true));
2018-12-13 13:39:08 +05:30
expect(eventHub.$emit).toHaveBeenCalled();
2017-09-10 17:25:29 +05:30
});
2019-07-31 22:56:46 +05:30
it('has a ref named `input`', () => {
expect(vm.$refs.input).not.toBeNull();
});
2017-09-10 17:25:29 +05:30
});