Skip to content

Commit fd6e430

Browse files
committed
IDVA5-2197 Register an ACSP - Allow Previously Closed/ Ceased ACSPs to Access Registration Service -undoing the any change related to this
1 parent 4d2f6a9 commit fd6e430

File tree

3 files changed

+32
-48
lines changed

3 files changed

+32
-48
lines changed

src/services/transaction/service.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,15 @@ export default class TransactionService {
195195
httpStatusCode: resp.status
196196
};
197197

198-
resource.resource = Mapping.camelCaseKeys<TransactionList>(resp.body);
198+
resource.resource = {
199+
items: resp.body.items ? resp.body.items.map((i) => ({
200+
id: i.id,
201+
updatedAt: i.updated_at,
202+
status: i.status,
203+
filings: i.filings,
204+
resumeJourneyUri: i.resume_journey_uri
205+
})) : []
206+
};
199207
return resource;
200208
}
201209
}

src/services/transaction/types.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,5 @@ export interface TransactionData {
7272
}
7373

7474
export interface Filing {
75-
status?: string;
76-
companyNumber?: string;
77-
type?: string;
75+
status?: String;
7876
}

test/services/transaction/service.spec.ts

Lines changed: 22 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -153,59 +153,37 @@ describe("transaction", () => {
153153
expect(castedData.errors[0]).to.equal("Unprocessable Entity");
154154
});
155155

156-
it("getTransactionsForResourceKind returns a transaction list with mapped filings", async () => {
157-
const mockResponseBody = {
158-
items: [
159-
{
160-
id: "txn1",
161-
updated_at: "2024-06-25T12:00:00Z",
162-
status: "closed",
163-
filings: {
156+
it("get transaction list for resource kind returns success response ", async () => {
157+
const itemsArray: TransactionData[] = ([
158+
{
159+
id: "123",
160+
status: "closed",
161+
filings: {
162+
testFiling: {
164163
status: "accepted",
165-
company_number: "AP000042",
164+
companyNumber: "AP000042",
166165
type: "acsp"
167-
},
168-
resume_journey_uri: "/resume/txn1"
166+
} as Filing
169167
}
170-
]
171-
};
168+
}
169+
]);
170+
171+
const transactionList: TransactionList = ({
172+
items: itemsArray
173+
});
172174

173175
const mockGetResponse = {
174176
status: 200,
175-
body: mockResponseBody
177+
body: transactionList
176178
};
177179

178-
sinon.stub(requestClient, "httpGet").resolves(mockGetResponse);
179-
const transaction: TransactionService = new TransactionService(requestClient);
180-
const data = await transaction.getTransactionsForResourceKind("req-123", "some-kind");
181-
180+
const mockRequest = sinon.stub(requestClient, "httpGet").resolves(mockGetResponse);
181+
const transaction : TransactionService = new TransactionService(requestClient);
182+
const data = await transaction.getTransactionsForResourceKind({} as string);
182183
expect(data.httpStatusCode).to.equal(200);
183184
const castedData: Resource<TransactionList> = data as Resource<TransactionList>;
184-
expect(castedData.resource?.items).to.have.lengthOf(1);
185-
const item = castedData.resource?.items[0];
186-
expect(item?.id).to.equal("txn1");
187-
expect(item?.updatedAt).to.equal("2024-06-25T12:00:00Z");
188-
expect(item?.status).to.equal("closed");
189-
expect(item?.filings).to.deep.equal({
190-
status: "accepted",
191-
companyNumber: "AP000042",
192-
type: "acsp"
193-
});
194-
expect(item?.resumeJourneyUri).to.equal("/resume/txn1");
195-
});
196-
197-
it("getTransactionsForResourceKind returns error response on failure", async () => {
198-
const mockGetResponse = {
199-
status: 500,
200-
error: "Internal Server Error"
201-
};
202-
203-
sinon.stub(requestClient, "httpGet").resolves(mockGetResponse);
204-
const transaction: TransactionService = new TransactionService(requestClient);
205-
const data = await transaction.getTransactionsForResourceKind("req-123", "some-kind");
206-
207-
expect(data.httpStatusCode).to.equal(500);
208-
const castedData: ApiErrorResponse = data as ApiErrorResponse;
209-
expect(castedData.errors[0]).to.equal("Internal Server Error");
185+
expect(castedData.resource?.items[0].id).to.equal(transactionList.items[0].id);
186+
expect(castedData.resource?.items[0].status).to.equal(transactionList.items[0].status);
187+
expect(castedData.resource?.items[0].filings).to.equal(transactionList.items[0].filings);
210188
});
211189
});

0 commit comments

Comments
 (0)