2017-04-06 01:13:06 +00:00
|
|
|
import Vue from 'vue';
|
2017-04-25 16:31:15 +00:00
|
|
|
import $ from 'jquery';
|
|
|
|
import '~/render_math';
|
|
|
|
import '~/render_gfm';
|
2017-04-21 20:34:11 +00:00
|
|
|
import issueTitle from '~/issue_show/issue_title_description.vue';
|
2017-04-25 16:31:15 +00:00
|
|
|
import issueShowData from './mock_data';
|
|
|
|
|
|
|
|
window.$ = $;
|
|
|
|
|
|
|
|
const issueShowInterceptor = (request, next) => {
|
|
|
|
next(request.respondWith(JSON.stringify(issueShowData), {
|
|
|
|
status: 200,
|
|
|
|
}));
|
|
|
|
};
|
2017-04-06 01:13:06 +00:00
|
|
|
|
2017-04-25 17:51:27 +00:00
|
|
|
describe('Issue Title', () => {
|
2017-04-25 16:31:15 +00:00
|
|
|
const comps = {
|
|
|
|
IssueTitleComponent: {},
|
|
|
|
};
|
2017-04-06 01:13:06 +00:00
|
|
|
|
|
|
|
beforeEach(() => {
|
2017-04-25 16:31:15 +00:00
|
|
|
comps.IssueTitleComponent = Vue.extend(issueTitle);
|
|
|
|
Vue.http.interceptors.push(issueShowInterceptor);
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
Vue.http.interceptors = _.without(
|
|
|
|
Vue.http.interceptors, issueShowInterceptor,
|
|
|
|
);
|
2017-04-06 01:13:06 +00:00
|
|
|
});
|
|
|
|
|
2017-04-25 16:31:15 +00:00
|
|
|
it('should render a title', (done) => {
|
|
|
|
const issueShowComponent = new comps.IssueTitleComponent({
|
2017-04-06 01:13:06 +00:00
|
|
|
propsData: {
|
2017-04-25 16:31:15 +00:00
|
|
|
candescription: '.css-stuff',
|
2017-04-06 01:13:06 +00:00
|
|
|
endpoint: '/gitlab-org/gitlab-shell/issues/9/rendered_title',
|
|
|
|
},
|
|
|
|
}).$mount();
|
|
|
|
|
2017-04-25 16:31:15 +00:00
|
|
|
// need setTimeout because actual setTimeout in code :P
|
|
|
|
setTimeout(() => {
|
2017-04-25 17:45:11 +00:00
|
|
|
expect(document.querySelector('title').innerText)
|
2017-04-25 16:31:15 +00:00
|
|
|
.toContain('this is a title');
|
2017-04-25 17:45:11 +00:00
|
|
|
expect(issueShowComponent.$el.querySelector('.title').innerHTML)
|
|
|
|
.toContain('<p>this is a title</p>');
|
|
|
|
expect(issueShowComponent.$el.querySelector('.wiki').innerHTML)
|
|
|
|
.toContain('<p>this is a description!</p>');
|
|
|
|
expect(issueShowComponent.$el.querySelector('.js-task-list-field').innerText)
|
|
|
|
.toContain('this is a description');
|
2017-04-25 16:31:15 +00:00
|
|
|
done();
|
2017-04-25 17:06:43 +00:00
|
|
|
}, 10);
|
|
|
|
// 10ms is just long enough for the update hook to fire
|
2017-04-06 01:13:06 +00:00
|
|
|
});
|
|
|
|
});
|