Skip to content

Commit

Permalink
ensure array of addresses is defined in RadarAutocompleteResponse (#125)
Browse files Browse the repository at this point in the history
  • Loading branch information
kochis authored Sep 12, 2023
1 parent 2d554ce commit 2811cd5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ export interface RadarAutocompleteParams {
}

export interface RadarAutocompleteResponse extends RadarResponse {
addresses: RadarAutocompleteAddress;
addresses: RadarAutocompleteAddress[];
}

export interface RadarSearchPlacesParams {
Expand Down
8 changes: 5 additions & 3 deletions test/radar.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ describe('Radar', () => {

// geocoding
const query = 'mock-query';
const addresses: RadarAddress = { geometry: { type: 'Point', coordinates: [0, 0] }, latitude, longitude };
const addresses: RadarAddress[] = [
{ geometry: { type: 'Point', coordinates: [0, 0] }, latitude, longitude },
];

// routing
const destination = {
Expand Down Expand Up @@ -364,10 +366,10 @@ describe('Radar', () => {
});

it('should call forward geocode', async () => {
geocodeStub.mockResolvedValue({ addresses: [addresses] });
geocodeStub.mockResolvedValue({ addresses });

const response = await Radar.forwardGeocode({ query });
expect(response.addresses).toEqual([addresses]);
expect(response.addresses).toEqual(addresses);
});
});

Expand Down

0 comments on commit 2811cd5

Please sign in to comment.