Skip to content

Commit 3ee7d9e

Browse files
authored
Merge pull request #790 from companieshouse/IDVA52197
IDVA5-2197 Register an ACSP - Allow Previously Closed/ Ceased ACSPs to Access Registration Service -added the mapping for the filing type
2 parents fee18b9 + 6c7f07c commit 3ee7d9e

File tree

2 files changed

+49
-23
lines changed

2 files changed

+49
-23
lines changed

src/services/transaction/service.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,11 @@ export default class TransactionService {
200200
id: i.id,
201201
updatedAt: i.updated_at,
202202
status: i.status,
203-
filings: i.filings,
203+
filings: {
204+
status: i.filings.status,
205+
companyNumber: i.filings.company_number,
206+
type: i.filings.type
207+
},
204208
resumeJourneyUri: i.resume_journey_uri
205209
})) : []
206210
};

test/services/transaction/service.spec.ts

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

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

179177
const mockGetResponse = {
180178
status: 200,
181-
body: transactionList
179+
body: mockResponseBody
182180
};
183181

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

0 commit comments

Comments
 (0)