2017-04-06 01:13:06 +00:00
|
|
|
import Vue from 'vue';
|
2017-04-25 16:31:15 +00:00
|
|
|
import '~/render_math';
|
|
|
|
import '~/render_gfm';
|
2017-05-10 14:05:58 +00:00
|
|
|
import issuableApp from '~/issue_show/components/app.vue';
|
|
|
|
import issueShowData from '../mock_data';
|
2017-04-25 16:31:15 +00:00
|
|
|
|
2017-05-02 21:01:23 +00:00
|
|
|
const issueShowInterceptor = data => (request, next) => {
|
|
|
|
next(request.respondWith(JSON.stringify(data), {
|
2017-04-25 16:31:15 +00:00
|
|
|
status: 200,
|
2017-05-02 21:01:23 +00:00
|
|
|
headers: {
|
2017-05-04 13:24:47 +00:00
|
|
|
'POLL-INTERVAL': 1,
|
2017-05-02 21:01:23 +00:00
|
|
|
},
|
2017-04-25 16:31:15 +00:00
|
|
|
}));
|
|
|
|
};
|
2017-04-06 01:13:06 +00:00
|
|
|
|
2017-05-11 08:32:41 +00:00
|
|
|
describe('Issuable output', () => {
|
2017-05-04 13:24:47 +00:00
|
|
|
document.body.innerHTML = '<span id="task_status"></span>';
|
|
|
|
|
2017-05-10 14:05:58 +00:00
|
|
|
let vm;
|
2017-04-06 01:13:06 +00:00
|
|
|
|
|
|
|
beforeEach(() => {
|
2017-05-10 14:05:58 +00:00
|
|
|
const IssuableDescriptionComponent = Vue.extend(issuableApp);
|
2017-05-02 21:01:23 +00:00
|
|
|
Vue.http.interceptors.push(issueShowInterceptor(issueShowData.initialRequest));
|
|
|
|
|
2017-05-10 14:05:58 +00:00
|
|
|
vm = new IssuableDescriptionComponent({
|
2017-04-06 01:13:06 +00:00
|
|
|
propsData: {
|
2017-05-10 14:05:58 +00:00
|
|
|
canUpdate: true,
|
2017-05-13 20:19:49 +00:00
|
|
|
endpoint: '/gitlab-org/gitlab-shell/issues/9/realtime_changes',
|
2017-05-10 14:05:58 +00:00
|
|
|
issuableRef: '#1',
|
|
|
|
initialTitle: '',
|
|
|
|
initialDescriptionHtml: '',
|
|
|
|
initialDescriptionText: '',
|
2017-04-06 01:13:06 +00:00
|
|
|
},
|
|
|
|
}).$mount();
|
2017-05-10 14:05:58 +00:00
|
|
|
});
|
2017-04-06 01:13:06 +00:00
|
|
|
|
2017-05-10 14:05:58 +00:00
|
|
|
afterEach(() => {
|
|
|
|
Vue.http.interceptors = _.without(Vue.http.interceptors, issueShowInterceptor);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should render a title/description and update title/description on update', (done) => {
|
2017-04-25 16:31:15 +00:00
|
|
|
setTimeout(() => {
|
2017-05-02 21:01:23 +00:00
|
|
|
expect(document.querySelector('title').innerText).toContain('this is a title (#1)');
|
2017-05-10 14:05:58 +00:00
|
|
|
expect(vm.$el.querySelector('.title').innerHTML).toContain('<p>this is a title</p>');
|
|
|
|
expect(vm.$el.querySelector('.wiki').innerHTML).toContain('<p>this is a description!</p>');
|
2017-05-10 17:50:14 +00:00
|
|
|
expect(vm.$el.querySelector('.js-task-list-field').value).toContain('this is a description');
|
2017-04-25 18:48:00 +00:00
|
|
|
|
2017-05-02 21:01:23 +00:00
|
|
|
Vue.http.interceptors.push(issueShowInterceptor(issueShowData.secondRequest));
|
2017-04-25 18:48:00 +00:00
|
|
|
|
2017-05-02 21:01:23 +00:00
|
|
|
setTimeout(() => {
|
|
|
|
expect(document.querySelector('title').innerText).toContain('2 (#1)');
|
2017-05-10 14:05:58 +00:00
|
|
|
expect(vm.$el.querySelector('.title').innerHTML).toContain('<p>2</p>');
|
|
|
|
expect(vm.$el.querySelector('.wiki').innerHTML).toContain('<p>42</p>');
|
2017-05-10 17:50:14 +00:00
|
|
|
expect(vm.$el.querySelector('.js-task-list-field').value).toContain('42');
|
2017-04-25 18:48:00 +00:00
|
|
|
|
2017-05-02 21:01:23 +00:00
|
|
|
done();
|
2017-05-04 13:24:47 +00:00
|
|
|
});
|
|
|
|
});
|
2017-04-06 01:13:06 +00:00
|
|
|
});
|
|
|
|
});
|