Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TS migration] Migrate 'GooglePlacesUtilsTest.js' test to TypeScript #36146

Merged
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
1 change: 1 addition & 0 deletions src/libs/GooglePlacesUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,4 @@ function getPlaceAutocompleteTerms(addressTerms: AddressTerm[]): GetPlaceAutocom
}

export {getAddressComponents, getPlaceAutocompleteTerms};
export type {AddressComponent, FieldsToExtract, AddressTerm};
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
import * as GooglePlacesUtils from '../../src/libs/GooglePlacesUtils';
/* 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',
'doesnt-exist': 'long_name',
country: 'long_name',
};

const addressComponents = [
const addressComponents: AddressComponent[] = [
{
long_name: 'Bushwick',
short_name: 'Bushwick',
Expand Down Expand Up @@ -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', () => {
Expand Down
Loading