diff --git a/src/services/transaction/types.ts b/src/services/transaction/types.ts index b585901e..5bdcd670 100644 --- a/src/services/transaction/types.ts +++ b/src/services/transaction/types.ts @@ -65,7 +65,9 @@ export interface TransactionData { id?: String; updatedAt?: Date; status?: String; - filings?: Map; + filings?: { + [key: string]: Filing; + }; } export interface Filing { diff --git a/test/services/transaction/service.spec.ts b/test/services/transaction/service.spec.ts index 0353d7c0..11da6bf5 100644 --- a/test/services/transaction/service.spec.ts +++ b/test/services/transaction/service.spec.ts @@ -3,7 +3,7 @@ import sinon from "sinon"; import TransactionService from "../../../src/services/transaction/service"; import { RequestClient } from "../../../src/http"; -import { Transaction, TransactionResource } from "../../../src/services/transaction"; +import { Transaction, TransactionData, TransactionList, TransactionResource } from "../../../src/services/transaction"; import { ApiErrorResponse, ApiResponse } from "../../../src/services/resource"; import { Resource } from "../../../src"; const expect = chai.expect; @@ -152,4 +152,30 @@ describe("transaction", () => { const castedData: ApiErrorResponse = data; expect(castedData.errors[0]).to.equal("Unprocessable Entity"); }); + + it("get transaction list for resource kind returns success response ", async () => { + const itemsArray: TransactionData[] = ([ + { + id: "123", + status: "closed" + } + ]); + + const transactionList: TransactionList = ({ + items: itemsArray + }); + + const mockGetResponse = { + status: 200, + body: transactionList + }; + + const mockRequest = sinon.stub(requestClient, "httpGet").resolves(mockGetResponse); + const transaction : TransactionService = new TransactionService(requestClient); + const data = await transaction.getTransactionsForResourceKind({} as string); + expect(data.httpStatusCode).to.equal(200); + const castedData: Resource = data as Resource; + expect(castedData.resource?.items[0].id).to.equal(transactionList.items[0].id); + expect(castedData.resource?.items[0].status).to.equal(transactionList.items[0].status); + }); });