Skip to content

Instantly share code, notes, and snippets.

@mateuszsokola
Created November 25, 2018 15:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mateuszsokola/2641bba5c73bde76b01439fc02996373 to your computer and use it in GitHub Desktop.
Save mateuszsokola/2641bba5c73bde76b01439fc02996373 to your computer and use it in GitHub Desktop.
import { Matchers } from '@pact-foundation/pact';
import fetchJob from '../fetchJob';
describe('Services', () => {
beforeAll(() => provider.setup());
afterAll(() => provider.finalize());
describe('fetchJob', () => {
beforeAll(() => provider.addInteraction({
state: 'has a job offer',
uponReceiving: 'a request for an job offer with id 1 and slug senior-front-end-developer',
withRequest: {
method: 'GET',
// endpoint on the back-end for web-ui side
path: '/v1/job/1-senior-front-end-developer',
headers: {
'Accept': Matchers.somethingLike('application/json')
}
},
willRespondWith: {
status: 200,
headers: {
'Content-Type': Matchers.somethingLike('application/json')
},
body: {
id: 1,
slug: 'senior-front-end-developer',
title: 'Senior Front End Developer',
createdAt: 'Sat Feb 10 2018 18:12:40 GMT+0100 (CET)',
salaryFrom: 4340000,
salaryTo: 5880000,
city: 'Vienna'
}
}
}));
it('returns a job offer', async () => {
const response = await fetchJob({ id: '1', slug: 'senior-front-end-developer'});
expect(response).toEqual({
id: 1,
slug: 'senior-front-end-developer',
title: 'Senior Front End Developer',
createdAt: 'Sat Feb 10 2018 18:12:40 GMT+0100 (CET)',
salaryFrom: 4340000,
salaryTo: 5880000,
city: 'Vienna'
});
});
});
it('successfully verifies', () => provider.verify())
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment