debian-mirror-gitlab/spec/contracts/consumer/specs/project/pipeline/index.spec.js
2022-08-27 11:52:29 +05:30

40 lines
1.1 KiB
JavaScript

import { pactWith } from 'jest-pact';
import { ProjectPipelines } from '../../../fixtures/project/pipeline/get_list_project_pipelines.fixture';
import { getProjectPipelines } from '../../../resources/api/project/pipelines';
const CONSUMER_NAME = 'Pipelines#index';
const CONSUMER_LOG = '../logs/consumer.log';
const CONTRACT_DIR = '../contracts/project/pipeline/index';
const PROVIDER_NAME = 'GET List project pipelines';
// API endpoint: /pipelines.json
pactWith(
{
consumer: CONSUMER_NAME,
provider: PROVIDER_NAME,
log: CONSUMER_LOG,
dir: CONTRACT_DIR,
},
(provider) => {
describe(PROVIDER_NAME, () => {
beforeEach(() => {
const interaction = {
...ProjectPipelines.scenario,
...ProjectPipelines.request,
willRespondWith: ProjectPipelines.success,
};
provider.addInteraction(interaction);
});
it('returns a successful body', async () => {
const pipelines = await getProjectPipelines({
url: provider.mockService.baseUrl,
});
expect(pipelines).toEqual(ProjectPipelines.body);
});
});
},
);