Commit 1fc9262e authored by winh's avatar winh

Handle Promise rejections in mr_widget_pipeline_spec.js

parent 50fffb5f
...@@ -86,12 +86,15 @@ describe('MRWidgetPipeline', () => { ...@@ -86,12 +86,15 @@ describe('MRWidgetPipeline', () => {
}); });
it('should render message with spinner', (done) => { it('should render message with spinner', (done) => {
Vue.nextTick(() => { Vue.nextTick()
expect(el.querySelector('.pipeline-id')).toBe(null); .then(() => {
expect(el.innerText.trim()).toBe('Waiting for pipeline...'); expect(el.querySelector('.pipeline-id')).toBe(null);
expect(el.querySelectorAll('i.fa.fa-spinner.fa-spin').length).toBe(1); expect(el.innerText.trim()).toBe('Waiting for pipeline...');
done(); expect(el.querySelectorAll('i.fa.fa-spinner.fa-spin').length).toBe(1);
}); done();
})
.then(done)
.catch(done.fail);
}); });
}); });
...@@ -112,39 +115,47 @@ describe('MRWidgetPipeline', () => { ...@@ -112,39 +115,47 @@ describe('MRWidgetPipeline', () => {
it('should list single stage', (done) => { it('should list single stage', (done) => {
pipeline.details.stages.splice(0, 1); pipeline.details.stages.splice(0, 1);
Vue.nextTick(() => { Vue.nextTick()
expect(el.querySelectorAll('.stage-container button').length).toEqual(1); .then(() => {
expect(el.innerText).toContain('with stage'); expect(el.querySelectorAll('.stage-container button').length).toEqual(1);
done(); expect(el.innerText).toContain('with stage');
}); })
.then(done)
.catch(done.fail);
}); });
it('should not have stages when there is no stage', (done) => { it('should not have stages when there is no stage', (done) => {
vm.mr.pipeline.details.stages = []; vm.mr.pipeline.details.stages = [];
Vue.nextTick(() => { Vue.nextTick()
expect(el.querySelectorAll('.stage-container button').length).toEqual(0); .then(() => {
done(); expect(el.querySelectorAll('.stage-container button').length).toEqual(0);
}); })
.then(done)
.catch(done.fail);
}); });
it('should not have coverage text when pipeline has no coverage info', (done) => { it('should not have coverage text when pipeline has no coverage info', (done) => {
vm.mr.pipeline.coverage = null; vm.mr.pipeline.coverage = null;
Vue.nextTick(() => { Vue.nextTick()
expect(el.querySelector('.js-mr-coverage')).toEqual(null); .then(() => {
done(); expect(el.querySelector('.js-mr-coverage')).toEqual(null);
}); })
.then(done)
.catch(done.fail);
}); });
it('should show CI error when there is a CI error', (done) => { it('should show CI error when there is a CI error', (done) => {
vm.mr.ciStatus = null; vm.mr.ciStatus = null;
Vue.nextTick(() => { Vue.nextTick()
expect(el.querySelectorAll('.js-ci-error').length).toEqual(1); .then(() => {
expect(el.innerText).toContain('Could not connect to the CI server'); expect(el.querySelectorAll('.js-ci-error').length).toEqual(1);
done(); expect(el.innerText).toContain('Could not connect to the CI server');
}); })
.then(done)
.catch(done.fail);
}); });
}); });
}); });
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