From 0052faea252bcafbc472ee5725b033a12711ee5d Mon Sep 17 00:00:00 2001 From: Julian Kobrynski Date: Thu, 8 Feb 2024 14:31:54 +0100 Subject: [PATCH 1/2] migrate GooglePlacesUtilsTest to TypeScript --- src/libs/GooglePlacesUtils.ts | 1 + ...ePlacesUtilsTest.js => GooglePlacesUtilsTest.ts} | 13 ++++++------- 2 files changed, 7 insertions(+), 7 deletions(-) rename tests/unit/{GooglePlacesUtilsTest.js => GooglePlacesUtilsTest.ts} (90%) diff --git a/src/libs/GooglePlacesUtils.ts b/src/libs/GooglePlacesUtils.ts index 43fac2b9a785..312a0dc61c1f 100644 --- a/src/libs/GooglePlacesUtils.ts +++ b/src/libs/GooglePlacesUtils.ts @@ -51,3 +51,4 @@ function getPlaceAutocompleteTerms(addressTerms: AddressTerm[]): GetPlaceAutocom } export {getAddressComponents, getPlaceAutocompleteTerms}; +export type {AddressComponent, FieldsToExtract, AddressTerm}; diff --git a/tests/unit/GooglePlacesUtilsTest.js b/tests/unit/GooglePlacesUtilsTest.ts similarity index 90% rename from tests/unit/GooglePlacesUtilsTest.js rename to tests/unit/GooglePlacesUtilsTest.ts index b94068f521ff..b34d859771e5 100644 --- a/tests/unit/GooglePlacesUtilsTest.js +++ b/tests/unit/GooglePlacesUtilsTest.ts @@ -1,13 +1,15 @@ +/* eslint-disable @typescript-eslint/naming-convention */ import * as GooglePlacesUtils from '../../src/libs/GooglePlacesUtils'; +import type {AddressComponent, AddressTerm, FieldsToExtract} from '../../src/libs/GooglePlacesUtils'; -const standardObjectToFind = { +const standardObjectToFind: FieldsToExtract = { sublocality: 'long_name', administrative_area_level_1: 'short_name', postal_code: 'long_name', 'doesnt-exist': 'long_name', }; -const objectWithCountryToFind = { +const objectWithCountryToFind: FieldsToExtract = { sublocality: 'long_name', administrative_area_level_1: 'short_name', postal_code: 'long_name', @@ -15,7 +17,7 @@ const objectWithCountryToFind = { country: 'long_name', }; -const addressComponents = [ +const addressComponents: AddressComponent[] = [ { long_name: 'Bushwick', short_name: 'Bushwick', @@ -43,10 +45,7 @@ const addressComponents = [ }, ]; -const autoCompleteTerms = [ - {offset: 0, value: 'Bangladesh Border Road'}, - {offset: 24, value: 'Bangladesh'}, -]; +const autoCompleteTerms: AddressTerm[] = [{value: 'Bangladesh Border Road'}, {value: 'Bangladesh'}]; describe('GooglePlacesUtilsTest', () => { describe('getAddressComponents', () => { From e98afd1a1282cf4ea9a9a49533bf365712479d3f Mon Sep 17 00:00:00 2001 From: Julian Kobrynski Date: Fri, 9 Feb 2024 10:04:34 +0100 Subject: [PATCH 2/2] modify imports to use @src --- tests/unit/GooglePlacesUtilsTest.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/unit/GooglePlacesUtilsTest.ts b/tests/unit/GooglePlacesUtilsTest.ts index b34d859771e5..9a7649158c8f 100644 --- a/tests/unit/GooglePlacesUtilsTest.ts +++ b/tests/unit/GooglePlacesUtilsTest.ts @@ -1,6 +1,6 @@ /* eslint-disable @typescript-eslint/naming-convention */ -import * as GooglePlacesUtils from '../../src/libs/GooglePlacesUtils'; -import type {AddressComponent, AddressTerm, FieldsToExtract} from '../../src/libs/GooglePlacesUtils'; +import * as GooglePlacesUtils from '@src/libs/GooglePlacesUtils'; +import type {AddressComponent, AddressTerm, FieldsToExtract} from '@src/libs/GooglePlacesUtils'; const standardObjectToFind: FieldsToExtract = { sublocality: 'long_name',