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

37 lines
1 KiB
JavaScript
Raw Normal View History

2018-10-15 14:42:47 +05:30
import MockAdapter from 'axios-mock-adapter';
2020-10-24 23:57:45 +05:30
import waitForPromises from 'helpers/wait_for_promises';
2018-10-15 14:42:47 +05:30
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', () => {
2020-05-24 23:13:21 +05:30
it('should store received data', () => {
2018-10-15 14:42:47 +05:30
mock.onGet('foo.json').reply(200, { id: '121123' });
2017-09-10 17:25:29 +05:30
mediator.fetchPipeline();
2020-05-24 23:13:21 +05:30
return waitForPromises().then(() => {
2018-10-15 14:42:47 +05:30
expect(mediator.store.state.pipeline).toEqual({ id: '121123' });
2020-05-24 23:13:21 +05:30
});
2017-09-10 17:25:29 +05:30
});
});
});