Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/us_street/Candidate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ export interface RawUsStreetCandidate {
last_line?: string;
delivery_point_barcode?: string;
smarty_key?: string;
smarty_key_ext?: string;
components?: RawUsStreetComponents;
metadata?: RawUsStreetMetadata;
analysis?: RawUsStreetAnalysis;
Expand All @@ -193,6 +194,7 @@ export default class Candidate {
lastLine: string;
deliveryPointBarcode: string;
smartyKey: string;
smartyKeyExt: string;
components: UsStreetComponents;
metadata: UsStreetMetadata;
analysis: UsStreetAnalysis;
Expand All @@ -207,6 +209,7 @@ export default class Candidate {
this.lastLine = responseData.last_line ?? "";
this.deliveryPointBarcode = responseData.delivery_point_barcode ?? "";
this.smartyKey = responseData.smarty_key ?? "";
this.smartyKeyExt = responseData.smarty_key_ext ?? "";

this.components = {} as UsStreetComponents;
if (responseData.components !== undefined) {
Expand Down
2 changes: 2 additions & 0 deletions tests/us_street/test_Candidate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ describe("A match candidate", function () {
last_line: "5",
delivery_point_barcode: "6",
smarty_key: "0000",
smarty_key_ext: "0",
components: {
urbanization: "7",
primary_number: "8",
Expand Down Expand Up @@ -96,6 +97,7 @@ describe("A match candidate", function () {
expect(candidate.lastLine).to.equal("5");
expect(candidate.deliveryPointBarcode).to.equal("6");
expect(candidate.smartyKey).to.equal("0000");
expect(candidate.smartyKeyExt).to.equal("0");

expect(candidate.components.urbanization).to.equal("7");
expect(candidate.components.primaryNumber).to.equal("8");
Expand Down
11 changes: 11 additions & 0 deletions tests/us_street/test_Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,17 @@ describe("A US Street client", function () {
});
});

it("maps smarty_key_ext from response to smartyKeyExt on candidate.", function () {
const expectedMockPayload = [{ smarty_key_ext: "0", input_index: 0 }];
let mockSender = new MockSenderWithResponse(expectedMockPayload);
const client = new Client(mockSender);
let lookup = new Lookup();

return client.send(lookup).then((_response) => {
expect(lookup.result[0].smartyKeyExt).to.equal("0");
});
});

it("attaches match candidates to their corresponding lookups.", function () {
const expectedMockPayload = [
{ delivery_line_1: "Address 0", input_index: 0 },
Expand Down