Skip to content

Commit 0d9504e

Browse files
committed
fixup create & lifecycle test
1 parent 7c73c66 commit 0d9504e

File tree

6 files changed

+794
-148
lines changed

6 files changed

+794
-148
lines changed

test/integration/batchSpec.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as assert from "assert";
2-
import {defaultApiClient, startNockRec} from "./helpers/integrationTestsHelpers";
2+
import {testingApiClient, startNockRec} from "./helpers/integrationTestsHelpers";
33
import {BatchFactory, RecipientAccountFactory, RecipientFactory} from "./factories/ApiFactory";
44

55
const batchFactory = new BatchFactory();
@@ -17,7 +17,7 @@ describe("Batch/Payment Integration", () => {
1717
const nockDone = await startNockRec('batch-create.json');
1818

1919
const batch = await batchFactory.createResource();
20-
const all = await defaultApiClient.batch.all();
20+
const all = await testingApiClient.batch.all();
2121

2222
assert.ok(batch);
2323
assert.ok(batch.id);
@@ -34,10 +34,10 @@ describe("Batch/Payment Integration", () => {
3434
});
3535
assert.strictEqual(batch.description, "Integration Test Update");
3636

37-
await defaultApiClient.batch.update(batch.id, {
37+
await testingApiClient.batch.update(batch.id, {
3838
description: "Integration Test Update 2",
3939
});
40-
batch = await defaultApiClient.batch.find(batch.id);
40+
batch = await testingApiClient.batch.find(batch.id);
4141
assert.ok(batch);
4242
assert.strictEqual(batch.description, "Integration Test Update 2");
4343
assert.strictEqual(batch.status, "open");
@@ -68,12 +68,12 @@ describe("Batch/Payment Integration", () => {
6868

6969
assert.ok(batch);
7070
assert.ok(batch.id);
71-
const findBatch = await defaultApiClient.batch.find(batch.id);
71+
const findBatch = await testingApiClient.batch.find(batch.id);
7272

7373
assert.ok(findBatch);
7474
assert.strictEqual(batch.totalPayments, 2);
7575

76-
let payments = await defaultApiClient.batch.paymentList(batch.id);
76+
let payments = await testingApiClient.batch.paymentList(batch.id);
7777
for (const item of payments) {
7878
assert.strictEqual(item.status, "pending");
7979
}
@@ -105,15 +105,15 @@ describe("Batch/Payment Integration", () => {
105105
assert.ok(batch);
106106
assert.ok(batch.id);
107107

108-
const summary = await defaultApiClient.batch.summary(batch.id);
108+
const summary = await testingApiClient.batch.summary(batch.id);
109109
assert.strictEqual(2, summary.detail["bank-transfer"].count, "Bad Count");
110110

111-
const quote = await defaultApiClient.batch.generateQuote(batch.id);
111+
const quote = await testingApiClient.batch.generateQuote(batch.id);
112112
assert.ok(quote, "failed to get quote");
113113

114114
// There's an issue here when it runs too quick. It returns "Operation In Progress"
115115
// Sleep when running against real API
116-
const start = await defaultApiClient.batch.startProcessing(batch.id);
116+
const start = await testingApiClient.batch.startProcessing(batch.id);
117117
assert.ok(start, "Failed to start");
118118

119119
nockDone();

test/integration/factories/ApiFactory.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import {Gateway} from "../../../lib";
2-
import {defaultApiClient} from "../helpers/integrationTestsHelpers";
2+
import {testingApiClient} from "../helpers/integrationTestsHelpers";
33

44
export abstract class ApiFactory {
5-
apiClient: Gateway = defaultApiClient;
5+
apiClient: Gateway = testingApiClient;
66

77
constructor(apiClient?: Gateway) {
88
if (apiClient) {
@@ -48,7 +48,7 @@ export class RecipientAccountFactory extends ApiFactory {
4848
}
4949

5050
export class RecipientFactory extends ApiFactory {
51-
private defaultAttrs = {
51+
defaultAttrs = {
5252
type: "individual",
5353
firstName: "Tom",
5454
lastName: `Jones`,
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
[
2+
{
3+
"scope": "https://api.railz.io:443",
4+
"method": "POST",
5+
"path": "/v1/recipients",
6+
"body": {
7+
"type": "individual",
8+
"firstName": "Tom",
9+
"lastName": "Jones",
10+
"email": "[email protected]",
11+
"address": {
12+
"street1": "123 Wolfstrasse",
13+
"city": "Berlin",
14+
"country": "DE",
15+
"postalCode": "123123"
16+
}
17+
},
18+
"status": 200,
19+
"response": {
20+
"ok": true,
21+
"recipient": {
22+
"id": "R-FVWX5hbqC6nyUmaxyVaDzb",
23+
"referenceId": "R-FVWX5hbqC6nyUmaxyVaDzb",
24+
"email": "[email protected]",
25+
"name": "Tom Jones",
26+
"lastName": "Jones",
27+
"firstName": "Tom",
28+
"legalName": "",
29+
"type": "individual",
30+
"status": "incomplete",
31+
"language": "en",
32+
"complianceStatus": "pending",
33+
"dob": null,
34+
"passport": "",
35+
"placeOfBirth": null,
36+
"updatedAt": "2022-10-17T13:05:14.510Z",
37+
"createdAt": "2022-10-17T13:05:14.510Z",
38+
"tags": [],
39+
"isPortalUser": false,
40+
"taxDeliveryType": "mail",
41+
"contactEmails": [],
42+
"occupation": "",
43+
"address": {
44+
"street1": "123 Wolfstrasse",
45+
"street2": "",
46+
"city": "Berlin",
47+
"postalCode": "123123",
48+
"country": "DE",
49+
"region": null,
50+
"phone": "",
51+
"phoneValidated": false
52+
},
53+
"compliance": {
54+
"status": "pending",
55+
"checkedAt": null
56+
},
57+
"gravatarUrl": "https://www.gravatar.com/avatar/47891e3b30e9fe3c5355801d4cbd5896?d=404",
58+
"governmentId": null,
59+
"ssn": null,
60+
"governmentIds": [],
61+
"birthplace": {
62+
"country": null,
63+
"region": null,
64+
"city": null
65+
},
66+
"citizenships": [],
67+
"routeType": "sepa",
68+
"routeMinimum": "0",
69+
"estimatedFees": "4",
70+
"accounts": [],
71+
"payoutMethod": null,
72+
"primaryCurrency": null,
73+
"riskScore": null,
74+
"merchantId": "M-W3mQuLjDafUGietRUqmeRz",
75+
"inactiveReasons": {
76+
"primaryAccount": "missing"
77+
},
78+
"taxWithholdingPercentage": null,
79+
"taxForm": null,
80+
"taxFormStatus": null
81+
}
82+
},
83+
"rawHeaders": [
84+
"Date",
85+
"Mon, 17 Oct 2022 13:05:14 GMT",
86+
"Content-Type",
87+
"application/json; charset=utf-8",
88+
"Content-Length",
89+
"1595",
90+
"Connection",
91+
"close",
92+
"Cache-Control",
93+
"no-store, no-cache",
94+
"Content-Security-Policy",
95+
"default-src 'self';base-uri 'self';block-all-mixed-content;font-src 'self' https: data:;frame-ancestors 'self';img-src 'self' data:;object-src 'none';script-src 'self';script-src-attr 'none';style-src 'self' https: 'unsafe-inline';upgrade-insecure-requests",
96+
"X-DNS-Prefetch-Control",
97+
"off",
98+
"Expect-CT",
99+
"max-age=0",
100+
"Strict-Transport-Security",
101+
"max-age=15552000; includeSubDomains",
102+
"X-Download-Options",
103+
"noopen",
104+
"X-Content-Type-Options",
105+
"nosniff",
106+
"X-Permitted-Cross-Domain-Policies",
107+
"none",
108+
"Referrer-Policy",
109+
"no-referrer",
110+
"X-XSS-Protection",
111+
"0",
112+
"Access-Control-Allow-Origin",
113+
"*",
114+
"X-Rate-Limit-Limit",
115+
"75",
116+
"X-Rate-Limit-Remaining",
117+
"74",
118+
"X-Rate-Limit-Reset",
119+
"1666011974",
120+
"Vary",
121+
"Origin",
122+
"ETag",
123+
"W/\"63b-5ydbC3cPF90xSeuDfOZL1sbFOB0\""
124+
],
125+
"responseIsBinary": false
126+
}
127+
]

0 commit comments

Comments
 (0)