gitlab-org--gitlab-foss/spec/frontend/pipelines/pipeline_details_mediator_spec.js

36 lines
1 KiB
JavaScript

import MockAdapter from 'axios-mock-adapter';
import axios from '~/lib/utils/axios_utils';
import PipelineMediator from '~/pipelines/pipeline_details_mediator';
import waitForPromises from 'helpers/wait_for_promises';
describe('PipelineMdediator', () => {
let mediator;
let mock;
beforeEach(() => {
mock = new MockAdapter(axios);
mediator = new PipelineMediator({ endpoint: 'foo.json' });
});
afterEach(() => {
mock.restore();
});
it('should set defaults', () => {
expect(mediator.options).toEqual({ endpoint: 'foo.json' });
expect(mediator.state.isLoading).toEqual(false);
expect(mediator.store).toBeDefined();
expect(mediator.service).toBeDefined();
});
describe('request and store data', () => {
it('should store received data', () => {
mock.onGet('foo.json').reply(200, { id: '121123' });
mediator.fetchPipeline();
return waitForPromises().then(() => {
expect(mediator.store.state.pipeline).toEqual({ id: '121123' });
});
});
});
});