debian-mirror-gitlab/spec/javascripts/pipelines/pipeline_details_mediator_spec.js
2017-09-10 17:25:29 +05:30

41 lines
1.1 KiB
JavaScript

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();
});
});
});
});