Skip to content

Commit 6506af2

Browse files
authored
Merge pull request #5 from zero-bites/add-balance-spec
[Test] Balance integration test (4/?)
2 parents 4ba939d + cc6d064 commit 6506af2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+10571
-970
lines changed

.env.test

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
TROLLEY_ENVIRONMENT="sandbox"
2+
TROLLEY_ACCESS_KEY="access-key"
3+
TROLLEY_SECRET_KEY="access-secret"

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ __MACOSX
1010
.vscode
1111
.idea
1212
dist/
13+
.env

.mocharc.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"ui": "bdd",
3+
"timeout": 15000,
4+
"extension": ["ts"],
5+
"spec": ["'test/integration/*Spec.ts'"],
6+
"require": ["ts-node/register", "test/hooks.ts"],
7+
"package": "./package.json"
8+
}

lib/BatchGateway.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ export class BatchGateway {
119119

120120
const result = await this.gateway.client.patch<types.Batch.Result>(endPoint, body);
121121

122-
return true;
122+
return Batch.factory(result.batch);
123123
}
124124

125125
/**

lib/InvoiceLine.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ export interface InvoiceLineInput {
1010
tags: string[];
1111
}
1212

13-
enum InvoiceLineCategory {
14-
'services',
15-
'rent',
16-
'royalties',
17-
'royalties_film',
18-
'prizes',
19-
'education',
20-
'refunds',
13+
export enum InvoiceLineCategory {
14+
'services' = 'services',
15+
'rent' = 'rent',
16+
'royalties' = 'royalties',
17+
'royalties_film' = 'royalties_film',
18+
'prizes' = 'prizes',
19+
'education' = 'education',
20+
'refunds' = 'refunds',
2121
}
2222

2323
export class InvoiceLine {

lib/OfflinePaymentGateway.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,11 @@ export class OfflinePaymentGateway {
7171
offlinePaymentId,
7272
);
7373

74-
const result = await this.gateway.client.patch<{ ok: boolean }>(
75-
endPoint,
76-
body,
77-
);
74+
const result = await this.gateway.client.patch<
75+
types.OfflinePayment.Response
76+
>(endPoint, body);
7877

79-
return true;
78+
return OfflinePayment.factory(result.offlinePayment);
8079
}
8180

8281
/**

lib/Payment.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import * as types from "./types";
88
*/
99
export class Payment {
1010
id: string = "";
11+
externalId: string = "";
1112
recipient: Recipient = {} as any;
1213

1314
status: string = "";

lib/PaymentGateway.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,12 @@ export class PaymentGateway {
7979
async update(paymentId: string, batchId: string, body: any) {
8080
const endPoint = buildURL("batches", batchId, "payments", paymentId);
8181

82-
const result = await this.gateway.client.patch<{ ok: boolean }>(
82+
const result = await this.gateway.client.patch<types.Payment.Result>(
8383
endPoint,
8484
body,
8585
);
8686

87-
return true;
87+
return Payment.factory(result.payment);
8888
}
8989

9090
/**

lib/RecipientGateway.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ export class RecipientGateway {
102102

103103
const result = await this.gateway.client.patch<types.Recipient.Response>(endPoint, body);
104104

105-
return true;
105+
return Recipient.factory(result.recipient);
106106
}
107107

108108
/**
@@ -120,7 +120,7 @@ export class RecipientGateway {
120120
return true;
121121
}
122122

123-
async search(page: number, pageSize: number, term: string) {
123+
async search(page: number = 1, pageSize: number = 10, term: string = "") {
124124
// tslint:disable-next-line:max-line-length
125125
const endPoint = buildURL('recipients');
126126
const query = querystring.stringify({

lib/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ export { Payment } from "./Payment";
1010
export { OfflinePayment } from "./OfflinePayment";
1111
export { Invoice } from "./Invoice";
1212

13+
if (process.env.NODE_ENV === "test") {
14+
// tslint:disable-next-line:no-var-requires no-require-imports
15+
require("dotenv").config();
16+
}
17+
1318
/**
1419
* Create a client for the Payment Rails JavasScript API
1520
* ```

0 commit comments

Comments
 (0)