Created
November 25, 2018 15:17
-
-
Save mateuszsokola/2641bba5c73bde76b01439fc02996373 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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