Skip to content

Commit 83a1a17

Browse files
authored
Merge pull request #787 from companieshouse/lp-857-add-filing-mode-to-transaction
Lp 857 add filing mode to transaction
2 parents f4994c0 + fb7b8e8 commit 83a1a17

File tree

3 files changed

+21
-14
lines changed

3 files changed

+21
-14
lines changed

src/services/transaction/service.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ export default class TransactionService {
119119
links: body.links,
120120
reference: body.reference,
121121
status: body.status,
122+
filingMode: body.filing_mode,
122123
kind: body.kind,
123124
companyName: body.company_name,
124125
companyNumber: body.company_number,

src/services/transaction/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export interface TransactionResource {
77
links?: {self: string},
88
reference: string,
99
status?: string,
10+
filing_mode?: string,
1011
kind?: string,
1112
company_name?: string,
1213
company_number: string,
@@ -35,6 +36,7 @@ export interface Transaction {
3536
links?: {self: string},
3637
reference: string,
3738
status?: string,
39+
filingMode?: string,
3840
kind?: string,
3941
companyName?: string,
4042
companyNumber?: string,

test/services/transaction/service.spec.ts

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ describe("transaction", () => {
3434

3535
expect(data.httpStatusCode).to.equal(401);
3636
const castedData: ApiErrorResponse = data;
37-
expect(castedData.errors[0]).to.equal("An error occurred");
37+
expect(castedData.errors?.[0]).to.equal("An error occurred");
3838
});
3939

4040
it("post maps the company field data items correctly", async () => {
@@ -69,11 +69,12 @@ describe("transaction", () => {
6969

7070
expect(data.httpStatusCode).to.equal(200);
7171
const castedData: Resource<Transaction> = data as Resource<Transaction>;
72-
expect(castedData.resource.companyName).to.equal(mockResponseBody.company_name);
73-
expect(castedData.resource.companyNumber).to.equal(mockResponseBody.company_number);
74-
expect(castedData.resource.links.self).to.equal(mockResponseBody.links.self);
75-
expect(castedData.resource.reference).to.equal(mockResponseBody.reference);
76-
expect(castedData.resource.description).to.equal(mockResponseBody.description);
72+
const resource = castedData.resource;
73+
expect(resource?.companyName).to.equal(mockResponseBody.company_name);
74+
expect(resource?.companyNumber).to.equal(mockResponseBody.company_number);
75+
expect(resource?.links?.self).to.equal(mockResponseBody.links?.self);
76+
expect(resource?.reference).to.equal(mockResponseBody.reference);
77+
expect(resource?.description).to.equal(mockResponseBody.description);
7778
});
7879

7980
it("get returns an error response on failure", async () => {
@@ -88,14 +89,15 @@ describe("transaction", () => {
8889

8990
expect(data.httpStatusCode).to.equal(401);
9091
const castedData: ApiErrorResponse = data;
91-
expect(castedData.errors[0]).to.equal("An error occurred");
92+
expect(castedData.errors?.[0]).to.equal("An error occurred");
9293
});
9394

9495
it("get maps the company field data items correctly", async () => {
9596
const mockResponseBody : TransactionResource = ({
9697
id: "12345678",
9798
company_name: "HELLO LTD",
9899
company_number: "88",
100+
filing_mode: "default",
99101
links: {
100102
self: "/self"
101103
},
@@ -114,11 +116,13 @@ describe("transaction", () => {
114116

115117
expect(data.httpStatusCode).to.equal(200);
116118
const castedData: Resource<Transaction> = data as Resource<Transaction>;
117-
expect(castedData.resource.companyName).to.equal(mockResponseBody.company_name);
118-
expect(castedData.resource.companyNumber).to.equal(mockResponseBody.company_number);
119-
expect(castedData.resource.links.self).to.equal(mockResponseBody.links.self);
120-
expect(castedData.resource.reference).to.equal(mockResponseBody.reference);
121-
expect(castedData.resource.description).to.equal(mockResponseBody.description);
119+
const resource = castedData.resource;
120+
expect(resource?.companyName).to.equal(mockResponseBody.company_name);
121+
expect(resource?.companyNumber).to.equal(mockResponseBody.company_number);
122+
expect(resource?.filingMode).to.equal(mockResponseBody.filing_mode);
123+
expect(resource?.links?.self).to.equal(mockResponseBody.links?.self);
124+
expect(resource?.reference).to.equal(mockResponseBody.reference);
125+
expect(resource?.description).to.equal(mockResponseBody.description);
122126
});
123127

124128
it("put returns successful response", async () => {
@@ -135,7 +139,7 @@ describe("transaction", () => {
135139

136140
expect(data.httpStatusCode).to.equal(202);
137141
const castedData: ApiResponse<Transaction> = data as ApiResponse<Transaction>;
138-
expect(castedData.headers["X-Payment-Required"]).to.equal("http://link-to-payment");
142+
expect(castedData.headers?.["X-Payment-Required"]).to.equal("http://link-to-payment");
139143
});
140144

141145
it("put returns an error response on failure", async () => {
@@ -150,7 +154,7 @@ describe("transaction", () => {
150154

151155
expect(data.httpStatusCode).to.equal(422);
152156
const castedData: ApiErrorResponse = data;
153-
expect(castedData.errors[0]).to.equal("Unprocessable Entity");
157+
expect(castedData.errors?.[0]).to.equal("Unprocessable Entity");
154158
});
155159

156160
it("get transaction list for resource kind returns success response ", async () => {

0 commit comments

Comments
 (0)