debian-mirror-gitlab/spec/javascripts/pipelines/pipeline_details_mediator_spec.js

37 lines
977 B
JavaScript
Raw Normal View History

2018-10-15 14:42:47 +05:30
import MockAdapter from 'axios-mock-adapter';
import axios from '~/lib/utils/axios_utils';
2018-03-27 19:54:05 +05:30
import PipelineMediator from '~/pipelines/pipeline_details_mediator';
2017-09-10 17:25:29 +05:30
describe('PipelineMdediator', () => {
let mediator;
2018-10-15 14:42:47 +05:30
let mock;
2017-09-10 17:25:29 +05:30
beforeEach(() => {
2018-10-15 14:42:47 +05:30
mock = new MockAdapter(axios);
mediator = new PipelineMediator({ endpoint: 'foo.json' });
});
afterEach(() => {
mock.restore();
2017-09-10 17:25:29 +05:30
});
it('should set defaults', () => {
2018-10-15 14:42:47 +05:30
expect(mediator.options).toEqual({ endpoint: 'foo.json' });
2017-09-10 17:25:29 +05:30
expect(mediator.state.isLoading).toEqual(false);
expect(mediator.store).toBeDefined();
expect(mediator.service).toBeDefined();
});
describe('request and store data', () => {
2018-10-15 14:42:47 +05:30
it('should store received data', done => {
mock.onGet('foo.json').reply(200, { id: '121123' });
2017-09-10 17:25:29 +05:30
mediator.fetchPipeline();
setTimeout(() => {
2018-10-15 14:42:47 +05:30
expect(mediator.store.state.pipeline).toEqual({ id: '121123' });
2017-09-10 17:25:29 +05:30
done();
2018-10-15 14:42:47 +05:30
}, 0);
2017-09-10 17:25:29 +05:30
});
});
});