Skip to content

Instantly share code, notes, and snippets.

@vinchbr
Last active January 28, 2019 23:38
Show Gist options
  • Save vinchbr/dad7258068a00d4ea429ca67b9572ba5 to your computer and use it in GitHub Desktop.
Save vinchbr/dad7258068a00d4ea429ca67b9572ba5 to your computer and use it in GitHub Desktop.
/* eslint-disable*/
import { expect } from 'chai';
import provider from './pactSetup';
import { searchRequest } from '../../src/services/search/api';
import { noFilter } from './responses/evaluatedTransferMatchers';
const SEARCH_RESPONSE = require('./responses/evaluatedTransferNoFilter.json');
describe('Evaluated Transfer Pact', () => {
before(() => provider.setup());
after(() => provider.finalize());
afterEach(() => provider.verify());
context('get /evaluated_transfers', () => {
before( async () => {
const interaction = {
state: 'I have a list of transfer',
uponReceiving: 'a request for all transfers',
withRequest: {
method: 'GET',
query: 'page_size=5000',
path: '/api/v1/evaluated_transfers',
},
willRespondWith: {
status: 200,
headers: { 'Content-Type': 'application/json' },
body: noFilter,
}
};
await provider.addInteraction(interaction);
});
it('returns the correct response', async() => {
await searchRequest().then((response) => {
expect(response).to.deep.eql(SEARCH_RESPONSE);
})
});
});
});
{
"pageCursorId": "20181221000123",
"evaluatedTransfers": [
{
"transferId": "20181221000123",
"amount": 0,
"initiationTime": "2018-12-21T12:34:33.649",
"method": "ACH",
"direction": "WITHDRAWAL",
"state": "ReviewPending",
"instructionSource": "WEB_SERVICE",
"achDetails": {
"achRelationshipId": "5bca5af7e4b0eae344f76411",
"bankAccount": {
"type": "CHECKING",
"number": "123456789",
"identifier": {
"type": "RoutingNumber",
"value": "121000358"
}
}
},
"withdrawalDetails": {
"isFullDisbursement": true,
"calculatedAmountAvailable": {
"account": "9YY19276",
"total": 0.00,
"unAdjustedTotal": 0.00,
"startDayCashAvailable": 0.00,
"pendingDebitInterest": 0.00,
"pendingDebitDividends": 0.00,
"fullyPaidUnsettledFunds": 0.00,
"includesFullyPaidUnsettledFunds": false,
"totalDeposits": 0.00,
"totalDisbursements": 0.00,
"disbursements": [
{
"transferId": "20181218000162",
"mechanism": "ACH",
"state": "Postponed",
"requestedAmount": 0,
"feeAmount": 0,
"totalCustomerDebitAmount": 0,
"disbursementType": "FULL_BALANCE",
"transferTime": "2018-12-18T21:21:28.619Z",
"fundsPostedDate": null
},
{
"transferId": "20181218000226",
"mechanism": "ACH",
"state": "Postponed",
"requestedAmount": 0,
"feeAmount": 0,
"totalCustomerDebitAmount": 0,
"disbursementType": "FULL_BALANCE",
"transferTime": "2018-12-18T23:41:04.178Z",
"fundsPostedDate": null
},
{
"transferId": "20181218000331",
"mechanism": "ACH",
"state": "Postponed",
"requestedAmount": 0,
"feeAmount": 0,
"totalCustomerDebitAmount": 0,
"disbursementType": "FULL_BALANCE",
"transferTime": "2018-12-19T00:58:01.952Z",
"fundsPostedDate": null
},
{
"transferId": "20181219000049",
"mechanism": "ACH",
"state": "Postponed",
"requestedAmount": 0,
"feeAmount": 0,
"totalCustomerDebitAmount": 0,
"disbursementType": "FULL_BALANCE",
"transferTime": "2018-12-19T16:22:51.383Z",
"fundsPostedDate": null
},
{
"transferId": "20181219000119",
"mechanism": "ACH",
"state": "Postponed",
"requestedAmount": 0,
"feeAmount": 0,
"totalCustomerDebitAmount": 0,
"disbursementType": "FULL_BALANCE",
"transferTime": "2018-12-19T17:03:37.125Z",
"fundsPostedDate": null
},
{
"transferId": "20181219000236",
"mechanism": "ACH",
"state": "Postponed",
"requestedAmount": 0,
"feeAmount": 0,
"totalCustomerDebitAmount": 0,
"disbursementType": "FULL_BALANCE",
"transferTime": "2018-12-19T20:04:59.722Z",
"fundsPostedDate": null
},
{
"transferId": "20181219000453",
"mechanism": "ACH",
"state": "Postponed",
"requestedAmount": 0,
"feeAmount": 0,
"totalCustomerDebitAmount": 0,
"disbursementType": "FULL_BALANCE",
"transferTime": "2018-12-20T00:46:31.107Z",
"fundsPostedDate": null
},
{
"transferId": "20181220000093",
"mechanism": "ACH",
"state": "Postponed",
"requestedAmount": 0,
"feeAmount": 0,
"totalCustomerDebitAmount": 0,
"disbursementType": "FULL_BALANCE",
"transferTime": "2018-12-20T17:19:41.874Z",
"fundsPostedDate": null
},
{
"transferId": "20181220000253",
"mechanism": "ACH",
"state": "Postponed",
"requestedAmount": 0,
"feeAmount": 0,
"totalCustomerDebitAmount": 0,
"disbursementType": "FULL_BALANCE",
"transferTime": "2018-12-20T20:25:19.947Z",
"fundsPostedDate": null
},
{
"transferId": "20181220000443",
"mechanism": "ACH",
"state": "Postponed",
"requestedAmount": 0,
"feeAmount": 0,
"totalCustomerDebitAmount": 0,
"disbursementType": "FULL_BALANCE",
"transferTime": "2018-12-20T23:38:56.469Z",
"fundsPostedDate": null
},
{
"transferId": "20181221000058",
"mechanism": "ACH",
"state": "Postponed",
"requestedAmount": 0,
"feeAmount": 0,
"totalCustomerDebitAmount": 0,
"disbursementType": "FULL_BALANCE",
"transferTime": "2018-12-21T17:18:42.134Z",
"fundsPostedDate": null
}
],
"recentDeposits": [],
"recentDepositsThreshold": 0.00
},
"iraDistributionDetails": null
},
"depositDetails": null,
"accountDetails": {
"accountNumber": "9YY19276",
"openedDate": "2016-01-25",
"isActive": false,
"isRetirementAccount": false,
"accountRegistration": "INDIVIDUAL",
"correspondent": {
"code": "ABC1",
"name": "CLEARING CORP - FIRM ACCOUNTS (ABC1)",
"deposit": 0.0
}
},
"hasActionResolvableByCurrentUser": true,
"hasActionAssignedToCurrentUser": true,
"prescribedActions": [
{
"type": "RestrictionCode",
"status": "OPEN",
"reason": "Account is Restricted. Code:NO_FUNDS_OUT",
"isResolvableByCurrentUser": true,
"resolution": null
},
{
"type": "OpenMarginCall",
"status": "OPEN",
"reason": "Margin call(s) on account.",
"isResolvableByCurrentUser": true,
"resolution": null
}
],
"auditEvents": [],
"batchId": null
}
]
}
import { Matchers } from '@pact-foundation/pact';
const { like, term, eachLike } = Matchers;
const disbursementsMatchers = {
transferId: term({
matcher: '\\d{14}',
generate: '20181218000162',
}),
mechanism: term({
matcher: '^(ACH|WIRE|CHECK)$',
generate: 'ACH',
}),
state: term({
matcher: '^(ReviewPending|Approved|FundsPosted|SentToBank|Completed|RejectedFundsNotPosted|RejectedFundsNotSentToBank|RejectedUnapproved|RejectedValidationFailed|SendToBankFailed|FundsReturned|Postponed|Canceled)$',
generate: 'ReviewPending',
}),
requestedAmount: like(0),
feeAmount: like(0),
totalCustomerDebitAmount: like(0),
disbursementType: like('FULL_BALANCE'),
transferTime: like('2018-12-18T21:21:28.619Z'),
fundsPostedDate: null,
};
const noFilter = {
pageCursorId: term({
matcher: '^(\\d{14})$',
generate: '20181221000123',
}),
evaluatedTransfers: eachLike(
{
transferId: term({
matcher: '^(\\d{14})$',
generate: '20181221000123',
}),
amount: like(0),
initiationTime: like('2018-12-21T12:34:33.649'),
method: term({
matcher: '^(ACH|WIRE|CHECK)$',
generate: 'ACH',
}),
direction: term({
matcher: '^(WITHDRAWAL|DEPOSIT)$',
generate: 'WITHDRAWAL',
}),
state: term({
matcher: '^(ReviewPending|Approved|FundsPosted|SentToBank|Completed|RejectedFundsNotPosted|RejectedFundsNotSentToBank|RejectedUnapproved|RejectedValidationFailed|SendToBankFailed|FundsReturned|Postponed|Canceled)$',
generate: 'ReviewPending',
}),
instructionSource: term({
matcher: '^(EMPLOYEE|WEB_SERVICE|CORRESPONDENT_EMPLOYEE|APP2)$',
generate: 'WEB_SERVICE',
}),
achDetails: {
achRelationshipId: like('5bca5af7e4b0eae344f76411'),
bankAccount: {
type: 'CHECKING',
number: term({
matcher: '^(\\d{9})$',
generate: '123456789',
}),
identifier: {
type: 'RoutingNumber',
value: term({
matcher: '^(\\d{9})$',
generate: '121000358',
}),
},
},
},
withdrawalDetails: {
isFullDisbursement: like(true),
calculatedAmountAvailable: {
account: term({
generate: '9YY19276',
matcher: '^(\\w{3}\\d{5})$',
}),
total: like(0.00),
unAdjustedTotal: like(0.00),
startDayCashAvailable: like(0.00),
pendingDebitInterest: like(0.00),
pendingDebitDividends: like(0.00),
fullyPaidUnsettledFunds: like(0.00),
includesFullyPaidUnsettledFunds: like(false),
totalDeposits: like(0.00),
totalDisbursements: like(0.00),
disbursements: eachLike(disbursementsMatchers, { min: 11 }),
recentDeposits: [],
recentDepositsThreshold: like(0.00),
},
iraDistributionDetails: null,
},
depositDetails: null,
accountDetails: {
accountNumber: term({
generate: '9YY19276',
matcher: '^(\\w{3}\\d{5})$',
}),
openedDate: like('2016-01-25'),
isActive: like(false),
isRetirementAccount: like(false),
accountRegistration: like('INDIVIDUAL'),
correspondent: {
code: like('ABC1'),
name: like('CLEARING CORP - FIRM ACCOUNTS (ABC1)'),
deposit: like(0.0),
},
},
hasActionResolvableByCurrentUser: true,
hasActionAssignedToCurrentUser: true,
prescribedActions: [
{
type: like('RestrictionCode'),
status: like('OPEN'),
reason: like('Account is Restricted. Code:NO_FUNDS_OUT'),
isResolvableByCurrentUser: like(true),
resolution: null,
},
{
type: like('OpenMarginCall'),
status: like('OPEN'),
reason: like('Margin call(s) on account.'),
isResolvableByCurrentUser: like(true),
resolution: null,
},
],
auditEvents: [],
batchId: null,
}),
};
module.exports = { noFilter };
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment