Skip to content
This repository has been archived by the owner on Jul 15, 2024. It is now read-only.

Commit

Permalink
Updated getTransactionChain
Browse files Browse the repository at this point in the history
Added Test and updated getTransactionChain
  • Loading branch information
dano-giftbit committed Feb 6, 2019
1 parent e10c549 commit cc228ff
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/params/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export * from "./transactions/ListTransactionsParams";
export * from "./transactions/ReverseParams";
export * from "./transactions/TransferParams";
export * from "./transactions/VoidPendingParams";
export * from "./transactions/GetTransactionChainParams";

export * from "./values/ChangeValuesCodeParams";
export * from "./values/CreateValueParams";
Expand Down
2 changes: 1 addition & 1 deletion src/params/transactions/GetTransactionChainParams.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {Transaction} from "../../model";
import {LightrailResponse} from "../LightrailResponse";

export interface GetTransactionChainResponse extends LightrailResponse<Transaction> {
export interface GetTransactionChainResponse extends LightrailResponse<Transaction[]> {
}
35 changes: 35 additions & 0 deletions src/transactions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,41 @@ describe("transactions", () => {
});
});

describe("getTransactionChain", () => {
it("successfully captures a pending transaction and fetches the chain", async () => {
const debitTxId = uuid.v4().substring(0, 24);
const captureTxId = uuid.v4().substring(0, 24);

const debitTx = await Lightrail.transactions.debit({
id: debitTxId,
currency: "USD",
amount: 100,
source: {
rail: "lightrail",
valueId: valueId
},
pending: true
});

chai.assert.isNotNull(debitTx);
chai.assert.equal(debitTx.body.transactionType, "debit");

const captureTx = await Lightrail.transactions.capturePending(debitTx.body, {
id: captureTxId
});

chai.assert.isNotNull(captureTx);
chai.assert.equal(captureTx.body.transactionType, "capture");

const transactionChain = await Lightrail.transactions.getTransactionChain(debitTxId);

chai.assert.isNotNull(transactionChain);
chai.assert.equal(transactionChain.body.length, 2);
chai.assert.isNotNull(transactionChain.body.find(p => p.id === debitTxId));
chai.assert.isNotNull(transactionChain.body.find(p => p.id === captureTxId));
});
});

describe("getTransaction()", () => {
it("successfully fetches a transaction by id", async () => {
const transaction = await getTransaction(creditId);
Expand Down
2 changes: 1 addition & 1 deletion src/transactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
CreditResponse,
DebitParams,
DebitResponse,
GetTransactionChainResponse,
GetTransactionResponse,
ListTransactionsParams,
ListTransactionsResponse,
Expand All @@ -21,7 +22,6 @@ import {
VoidPendingResponse
} from "./params";
import {Transaction} from "./model";
import {GetTransactionChainResponse, TransactionChainResponse} from "./params/transactions/GetTransactionChainParams";

export async function checkout(params: CheckoutParams): Promise<CheckoutResponse> {
if (!params) {
Expand Down

0 comments on commit cc228ff

Please sign in to comment.