Commit f6df1357 authored by Regis's avatar Regis

test realtime changes and hit more branches

parent 290cba5b
...@@ -7,9 +7,12 @@ import issueShowData from './mock_data'; ...@@ -7,9 +7,12 @@ import issueShowData from './mock_data';
window.$ = $; window.$ = $;
const issueShowInterceptor = (request, next) => { const issueShowInterceptor = data => (request, next) => {
next(request.respondWith(JSON.stringify(issueShowData), { next(request.respondWith(JSON.stringify(data), {
status: 200, status: 200,
headers: {
'POLL-INTERVAL': 1,
},
})); }));
}; };
...@@ -22,16 +25,15 @@ describe('Issue Title', () => { ...@@ -22,16 +25,15 @@ describe('Issue Title', () => {
beforeEach(() => { beforeEach(() => {
comps.IssueTitleComponent = Vue.extend(issueTitle); comps.IssueTitleComponent = Vue.extend(issueTitle);
Vue.http.interceptors.push(issueShowInterceptor);
}); });
afterEach(() => { afterEach(() => {
Vue.http.interceptors = _.without( Vue.http.interceptors = _.without(Vue.http.interceptors, issueShowInterceptor);
Vue.http.interceptors, issueShowInterceptor,
);
}); });
it('should render a title', (done) => { it('should render a title/description and update title/description on update', (done) => {
Vue.http.interceptors.push(issueShowInterceptor(issueShowData.initialRequest));
const issueShowComponent = new comps.IssueTitleComponent({ const issueShowComponent = new comps.IssueTitleComponent({
propsData: { propsData: {
candescription: '.css-stuff', candescription: '.css-stuff',
...@@ -41,22 +43,21 @@ describe('Issue Title', () => { ...@@ -41,22 +43,21 @@ describe('Issue Title', () => {
// need setTimeout because actual setTimeout in code :P // need setTimeout because actual setTimeout in code :P
setTimeout(() => { setTimeout(() => {
expect(document.querySelector('title').innerText) expect(document.querySelector('title').innerText).toContain('this is a title (#1)');
.toContain('this is a title (#1)'); 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('.title').innerHTML) expect(issueShowComponent.$el.querySelector('.js-task-list-field').innerText).toContain('this is a description');
.toContain('<p>this is a title</p>');
expect(issueShowComponent.$el.querySelector('.wiki').innerHTML)
.toContain('<p>this is a description!</p>');
const hiddenText = issueShowComponent.$el Vue.http.interceptors.push(issueShowInterceptor(issueShowData.secondRequest));
.querySelector('.js-task-list-field').innerText;
expect(hiddenText) setTimeout(() => {
.toContain('this is a description'); expect(document.querySelector('title').innerText).toContain('2 (#1)');
expect(issueShowComponent.$el.querySelector('.title').innerHTML).toContain('<p>2</p>');
expect(issueShowComponent.$el.querySelector('.wiki').innerHTML).toContain('<p>42</p>');
expect(issueShowComponent.$el.querySelector('.js-task-list-field').innerText).toContain('42');
done(); done();
}, 10);
}, 10); }, 10);
// 10ms is just long enough for the update hook to fire // 10ms is just long enough for the update hook to fire
}); });
......
export default { export default {
title: '<p>this is a title</p>', initialRequest: {
title_text: 'this is a title', title: '<p>this is a title</p>',
description: '<p>this is a description!</p>', title_text: 'this is a title',
description_text: 'this is a description', description: '<p>this is a description!</p>',
issue_number: 1, description_text: 'this is a description',
task_status: '2/4 completed', issue_number: 1,
task_status: '2 of 4 completed',
},
secondRequest: {
title: '<p>2</p>',
title_text: '2',
description: '<p>42</p>',
description_text: '42',
issue_number: 1,
task_status: '0 of 0 completed',
},
}; };
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment