Skip to content

Commit

Permalink
test: fix places/photo test
Browse files Browse the repository at this point in the history
  • Loading branch information
usefulthink committed Dec 12, 2023
1 parent 52b256f commit 6ff4412
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 9 deletions.
22 changes: 17 additions & 5 deletions e2e/places/photo.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,26 @@
*/

import { placePhoto } from "../../src/places/photo";
import { placeDetails } from "../../src/places/details";

test("photo should return correct result", async () => {
const placeDetailsResponse = await placeDetails({
params: {
// The Museum of Modern Art, 11 W 53rd St, New York
place_id: "ChIJKxDbe_lYwokRVf__s8CPn-o",
key: process.env.GOOGLE_MAPS_API_KEY_UNRESTRICTED,
fields: ["place_id", "photo"],
},
});

const [photo] = placeDetailsResponse.data.result.photos;
const { photo_reference: photoreference } = photo;

const params = {
photoreference:
"AZose0kqzNAxzQSLYC-kxAidG_FkCelqG6lXa-05yhbKfwfGd0Agu4YXSjvArtNEYLC8CiCvQb4uxQzfn2fZi2kzxeMBgtOHmbo0c8eqMx_YPVNRCjjPL_kA77NOWF5wOS2ub6ZQlM0G8XibN93burBky0JLCE5sf-C6gLVEG74yiPYoK8id",
maxwidth: 100,
maxheight: 100,
key: process.env.GOOGLE_MAPS_API_KEY,
photoreference,
maxwidth: 1000,
maxheight: 1000,
key: process.env.GOOGLE_MAPS_API_KEY_UNRESTRICTED,
};
const r = await placePhoto({ params: params, responseType: "arraybuffer" });

Expand Down
1 change: 0 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,5 @@ module.exports = {
transformIgnorePatterns: [
"/node_modules/(?!(axios|retry-axios|query-string|decode-uri-component|split-on-first|filter-obj)/)",
],
collectCoverage: true,
collectCoverageFrom: ["src/**/([a-zA-Z_]*).{js,ts}", "!**/*.test.{js,ts}"],
};
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@
"docs": "rm -rf docs/ && typedoc src/index.ts",
"prepack": "npm run build",
"pretest": "npm run build",
"test": "jest ./src/* && npm run test:loading",
"test": "jest --runInBand --collectCoverage ./src/* && npm run test:loading",
"test:loading": "./test-module-loading.sh",
"test:e2e": "jest ./e2e/*",
"test:all": "jest",
"test:e2e": "jest --runInBand ./e2e/*",
"test:all": "jest --runInBand",
"format": "eslint . --fix",
"lint": "eslint ."
},
Expand Down

0 comments on commit 6ff4412

Please sign in to comment.