@aceandtate/clicktoaddress
Advanced tools
Comparing version 0.1.12 to 0.1.13
@@ -23,2 +23,5 @@ "use strict"; | ||
US: function (result) { | ||
if (isNumeric(result.building_name) && !result.building_number) { | ||
return __assign(__assign({}, result), { building_name: "", building_number: result.building_name, postal_code: result.postal_code.split("-")[0] }); | ||
} | ||
return __assign(__assign({}, result), { postal_code: result.postal_code.split("-")[0] }); | ||
@@ -25,0 +28,0 @@ } |
{ | ||
"name": "@aceandtate/clicktoaddress", | ||
"version": "0.1.12", | ||
"version": "0.1.13", | ||
"description": "A clicktoaddress client", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -47,3 +47,3 @@ import { RetrieveArgs, RetrieveResponseResult } from "./types"; | ||
it("should not format the post code in another coutry", () => { | ||
it("should not format the post code in another country", () => { | ||
const result = mapRetrievedResult( | ||
@@ -56,2 +56,26 @@ { country: "NL" } as RetrieveArgs, | ||
}); | ||
it("should map US address' building number and name", () => { | ||
const result = mapRetrievedResult( | ||
{ country: "US" } as RetrieveArgs, | ||
{ building_name: "1", building_number: "", postal_code: "30328-6228" } as RetrieveResponseResult | ||
); | ||
expect(result).toEqual({ | ||
building_number: "1", | ||
building_name: "", | ||
postal_code: "30328" | ||
}); | ||
}); | ||
it("should skip mapping US address' when data seems valid", () => { | ||
const result = mapRetrievedResult( | ||
{ country: "US" } as RetrieveArgs, | ||
{ building_name: "x", building_number: "1", postal_code: "30328-6228" } as RetrieveResponseResult | ||
); | ||
expect(result).toEqual({ | ||
building_number: "1", | ||
building_name: "x", | ||
postal_code: "30328" | ||
}); | ||
}); | ||
}); |
@@ -23,2 +23,10 @@ import { RetrieveResponseResult, RetrieveArgs } from "./types"; | ||
US(result: RetrieveResponseResult) { | ||
if (isNumeric(result.building_name) && !result.building_number) { | ||
return { | ||
...result, | ||
building_name: "", | ||
building_number: result.building_name, | ||
postal_code: result.postal_code.split("-")[0] | ||
}; | ||
} | ||
return { | ||
@@ -25,0 +33,0 @@ ...result, |
Sorry, the diff of this file is not supported yet
91585
1057