From 491e32e6d2e117fd3c0310037caa0979c3c15ae5 Mon Sep 17 00:00:00 2001 From: Viviane Dias Date: Mon, 5 Aug 2024 15:39:02 -0300 Subject: [PATCH 1/2] fix(geolocation): returns "not_found" when city/state/zipcode is falsy --- packages/components/src/lib/geolocation/index.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/components/src/lib/geolocation/index.ts b/packages/components/src/lib/geolocation/index.ts index 9d87bd19..2e1d5dc9 100644 --- a/packages/components/src/lib/geolocation/index.ts +++ b/packages/components/src/lib/geolocation/index.ts @@ -16,10 +16,10 @@ const log = logger.child({ module: "geolocation" }); const getCityStateAndZipcode = ( addressComponents: AddressComponent ): Array => { - let state = ""; - let city = ""; - let zipcode = ""; - let country = ""; + let state = "not_found"; + let city = "not_found"; + let zipcode = "not_found"; + let country = "BR"; addressComponents.forEach(({ types, short_name: shortName }) => { if (types.includes("postal_code")) { @@ -59,9 +59,9 @@ const geolocationUnkown = ({ latitude: null, longitude: null, address: `Endereço não encontrado - ${address || zipcode}`, - state: null, - city: "ZERO_RESULTS", - cep: zipcode || null + state: "not_found", + city: "not_found", + cep: zipcode || "not_found" }); const parseZipcode = (zipcode: string): string => { From c266486b083e2c5a02390845306b72f6edd526bb Mon Sep 17 00:00:00 2001 From: Viviane Dias Date: Mon, 5 Aug 2024 15:41:54 -0300 Subject: [PATCH 2/2] test(geolocation): updates tests after contract change --- packages/components/src/lib/geolocation/geolocation.spec.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/components/src/lib/geolocation/geolocation.spec.ts b/packages/components/src/lib/geolocation/geolocation.spec.ts index f0af1c67..e8b1f1e3 100644 --- a/packages/components/src/lib/geolocation/geolocation.spec.ts +++ b/packages/components/src/lib/geolocation/geolocation.spec.ts @@ -57,9 +57,9 @@ describe("geolocation tests", () => { latitude: null, longitude: null, address: `Endereço não encontrado - ${validOutput.address}`, - state: null, - city: "ZERO_RESULTS", - cep: null + state: "not_found", + city: "not_found", + cep: "not_found" }; it("should return valid output if there are results", () => {