summaryrefslogtreecommitdiff
path: root/qa/contracts/consumer/specs/diffs.spec.js
blob: 5be2ed7ac00a9a9a725868788fa1be4f625f9a57 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
'use strict';

const { pactWith } = require('jest-pact');

const { Diffs } = require('../fixtures/diffs.fixture');
const { getDiffs } = require('../endpoints/merge_request');

pactWith(
  {
    consumer: 'Merge Request Page',
    provider: 'Merge Request Diffs Endpoint',
    log: '../logs/consumer.log',
    dir: '../contracts',
  },

  (provider) => {
    describe('Diffs Endpoint', () => {
      beforeEach(() => {
        const interaction = {
          ...Diffs.request,
          willRespondWith: Diffs.success,
        };
        return provider.addInteraction(interaction);
      });

      it('return a successful body', () => {
        return getDiffs({
          url: provider.mockService.baseUrl,
        }).then((diffs) => {
          expect(diffs).toEqual(Diffs.body);
        });
      });
    });
  },
);