Antonio Magana
09/11/2023, 8:49 PMAntonio Magana
09/11/2023, 8:51 PMimport axios from 'axios';
import { MatchersV3 } from '@pact-foundation/pact';
import provider from './pact';
import { getProcessingAccounts } from '../../src/rest/processing-accounts';
import { processingAccountMock } from '../mocks/processing-accounts';
const { like } = MatchersV3;
describe('onboarding/risk api test', () => {
describe('getting processing account status', () => {
beforeAll(() => {
provider
.given('I have a list of processing accounts')
.uponReceiving('a request for all processing accounts for a business')
.withRequest({
method: 'GET',
headers: {
Authorization: like('12345')
},
url: '/v2/processingAccounts',
query: {
businessId: '111222333'
}
})
.willRespondWith({
status: 200,
body: like(processingAccountMock)
});
});
it('should return the correct processing account format', async () => {
await provider.executeTest(async (mockserver) => {
axios.defaults.baseURL = mockserver.url;
const response = await getProcessingAccounts('111222333', '12345');
expect(response).toStrictEqual(processingAccountMock);
});
});
});
});
Antonio Magana
09/11/2023, 8:52 PMYousaf Nabi (pactflow.io)
path
not url
provider
.given('I have a list of dogs')
.uponReceiving('a request for all dogs with the builder pattern')
.withRequest({
method: 'GET',
path: '/dogs',
query: { from: 'today' },
headers: { Accept: 'application/json' },
})
.willRespondWith({
status: 200,
headers: { 'Content-Type': 'application/json' },
body: EXPECTED_BODY,
});
Antonio Magana
09/11/2023, 10:14 PM