Skip to content

Commit e68553d

Browse files
authored
Merge pull request #792 from companieshouse/IDVA52197
IDVA5-2197 Register an ACSP - Allow Previously Closed/ Ceased ACSPs to Access Registration Service -undoing the any change related to this
2 parents 386710c + e11db3f commit e68553d

File tree

2 files changed

+31
-45
lines changed

2 files changed

+31
-45
lines changed

src/services/transaction/service.ts

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

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

test/services/transaction/service.spec.ts

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

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: {
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: {
168167
status: "accepted",
169-
company_number: "AP000042",
168+
companyNumber: "AP000042",
170169
type: "acsp"
171-
},
172-
resume_journey_uri: "/resume/txn1"
170+
} as Filing
173171
}
174-
]
175-
};
172+
}
173+
]);
174+
175+
const transactionList: TransactionList = ({
176+
items: itemsArray
177+
});
176178

177179
const mockGetResponse = {
178180
status: 200,
179-
body: mockResponseBody
181+
body: transactionList
180182
};
181183

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-
184+
const mockRequest = sinon.stub(requestClient, "httpGet").resolves(mockGetResponse);
185+
const transaction : TransactionService = new TransactionService(requestClient);
186+
const data = await transaction.getTransactionsForResourceKind({} as string);
186187
expect(data.httpStatusCode).to.equal(200);
187188
const castedData: Resource<TransactionList> = data as Resource<TransactionList>;
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");
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);
214192
});
215193
});

0 commit comments

Comments
 (0)