diff options
author | Filipa Lacerda <filipa@gitlab.com> | 2017-06-02 16:24:42 +0300 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2017-06-02 16:24:42 +0300 |
commit | 228b73d5e9e68991017dbfc5d072c3831411c383 (patch) | |
tree | cc0435e671819a9e6e51600a2ab82b1659a65aba /spec/javascripts/pipelines/pipeline_details_mediator_spec.js | |
parent | 68112433e1c5537538004f6279cfe83d38aaaa0b (diff) |
Pipeline show view real time header section
Diffstat (limited to 'spec/javascripts/pipelines/pipeline_details_mediator_spec.js')
-rw-r--r-- | spec/javascripts/pipelines/pipeline_details_mediator_spec.js | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/spec/javascripts/pipelines/pipeline_details_mediator_spec.js b/spec/javascripts/pipelines/pipeline_details_mediator_spec.js new file mode 100644 index 00000000000..9fec2f61f78 --- /dev/null +++ b/spec/javascripts/pipelines/pipeline_details_mediator_spec.js @@ -0,0 +1,41 @@ +import Vue from 'vue'; +import PipelineMediator from '~/pipelines/pipeline_details_mediatior'; + +describe('PipelineMdediator', () => { + let mediator; + beforeEach(() => { + mediator = new PipelineMediator({ endpoint: 'foo' }); + }); + + it('should set defaults', () => { + expect(mediator.options).toEqual({ endpoint: 'foo' }); + expect(mediator.state.isLoading).toEqual(false); + expect(mediator.store).toBeDefined(); + expect(mediator.service).toBeDefined(); + }); + + describe('request and store data', () => { + const interceptor = (request, next) => { + next(request.respondWith(JSON.stringify({ foo: 'bar' }), { + status: 200, + })); + }; + + beforeEach(() => { + Vue.http.interceptors.push(interceptor); + }); + + afterEach(() => { + Vue.http.interceptors = _.without(Vue.http.interceptor, interceptor); + }); + + it('should store received data', (done) => { + mediator.fetchPipeline(); + + setTimeout(() => { + expect(mediator.store.state.pipeline).toEqual({ foo: 'bar' }); + done(); + }); + }); + }); +}); |