Skip to content

Commit

Permalink
fix: add missing place result properties (#453)
Browse files Browse the repository at this point in the history
  • Loading branch information
jpoehnelt committed Sep 25, 2020
1 parent 16293ff commit eba52ec
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 1 deletion.
47 changes: 46 additions & 1 deletion e2e/places/details.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,54 @@ test("details should return correct result", async () => {
const params = {
place_id: "ChIJKxDbe_lYwokRVf__s8CPn-o",
key: process.env.GOOGLE_MAPS_API_KEY,
fields: ["place_id", "name", "formatted_address"]
fields: ["place_id", "name", "formatted_address"],
};

const r = await placeDetails({ params: params });
expect(r.data.result.place_id).toBeDefined();
});

test("details should return all fields", async () => {
const params = {
place_id: "ChIJKxDbe_lYwokRVf__s8CPn-o",
key: process.env.GOOGLE_MAPS_API_KEY,
};

const r = await placeDetails({ params: params });

expect(r.data.result.address_components).toBeDefined();
expect(r.data.result.adr_address).toBeDefined();
expect(r.data.result.business_status).toBeDefined();
expect(r.data.result.formatted_address).toBeDefined();
expect(r.data.result.formatted_phone_number).toBeDefined();
expect(r.data.result.geometry).toBeDefined();
expect(r.data.result.icon).toBeDefined();
expect(r.data.result.international_phone_number).toBeDefined();
expect(r.data.result.name).toBeDefined();
expect(r.data.result.permanently_closed).toBeDefined();
expect(r.data.result.photos).toBeDefined();
expect(r.data.result.place_id).toBeDefined();
expect(r.data.result.plus_code).toBeDefined();
expect(r.data.result.rating).toBeDefined();
expect(r.data.result.reviews).toBeDefined();
expect(r.data.result.types).toBeDefined();
expect(r.data.result.url).toBeDefined();
expect(r.data.result.user_ratings_total).toBeDefined();
expect(r.data.result.utc_offset).toBeDefined();
expect(r.data.result.vicinity).toBeDefined();
expect(r.data.result.website).toBeDefined();

expect(r.data.result.reviews[0].author_name).toBeDefined();
expect(r.data.result.reviews[0].author_url).toBeDefined();
expect(r.data.result.reviews[0].language).toBeDefined();
expect(r.data.result.reviews[0].profile_photo_url).toBeDefined();
expect(r.data.result.reviews[0].rating).toBeDefined();
expect(r.data.result.reviews[0].relative_time_description).toBeDefined();
expect(r.data.result.reviews[0].text).toBeDefined();
expect(r.data.result.reviews[0].time).toBeDefined();

expect(r.data.result.photos[0].height).toBeDefined();
expect(r.data.result.photos[0].html_attributions).toBeDefined();
expect(r.data.result.photos[0].photo_reference).toBeDefined();
expect(r.data.result.photos[0].width).toBeDefined();
});
6 changes: 6 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
"codecov": ">=3.6.5",
"jest": "^25.2.2",
"nock": "^13.0.4",
"prettier": "^2.0.5",
"semantic-release": "^17.0.2",
"ts-jest": "^25.2.1",
"typedoc": "^0.19.2",
Expand Down
6 changes: 6 additions & 0 deletions src/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -294,8 +294,12 @@ export interface PlaceReview {
* For example, all the English reviews are tagged as 'en', and not 'en-AU' or 'en-UK' and so on.
*/
language: string;
/** the URL to the user's profile photo, if available. */
profile_photo_url: string;
/** the user's overall rating for this place. This is a whole number, ranging from 1 to 5. */
rating: number;
/* The time since review in relative terms, for example '7 months ago' */
relative_time_description: string;
/**
* the user's review. When reviewing a location with Google Places, text reviews are considered optional.
* Therefore, this field may by empty. Note that this field may include simple HTML markup.
Expand Down Expand Up @@ -435,6 +439,8 @@ interface PlaceData {
price_level: number;
/** contains the place's rating, from 1.0 to 5.0, based on aggregated user reviews. */
rating: number;
/** The total number of ratings from users */
user_ratings_total: number;
/**
* a JSON array of up to five reviews. If a `language` parameter was specified in the Place Details request,
* the Places Service will bias the results to prefer reviews written in that language.
Expand Down

0 comments on commit eba52ec

Please sign in to comment.