Skip to content

Commit 5495e35

Browse files
authored
feat: world geojson map (#43)
* wip * fix tests
1 parent 55aa8b7 commit 5495e35

File tree

6 files changed

+13
-6
lines changed

6 files changed

+13
-6
lines changed

maps/worldwide/world.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

src/config/google.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ const defaultMapOpts: google.maps.MapOptions = {
1616

1717
export const config: GoogleConfig = {
1818
svRequest: {
19+
maxRetries: 80,
1920
radius: 100,
2021
},
2122
streetview: {

src/config/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
export type GoogleConfig = {
1111
svRequest: {
1212
radius: number;
13+
maxRetries: number;
1314
};
1415
streetview: google.maps.StreetViewPanoramaOptions;
1516
map: Record<

src/maps/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import {generateMapData} from './helpers/generator';
22

33
export const MAPS = generateMapData(
4+
{
5+
collection: require('maps/worldwide/world.json'),
6+
category: 'Worldwide',
7+
},
48
{
59
collection: require('maps/regional/che-cantons.json'),
610
category: 'Switzerland',

src/redux/position/thunks.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,17 @@ export const getRandomStreetView = createAsyncThunk<
4242

4343
const reqDefaults: google.maps.StreetViewLocationRequest = {
4444
preference: randomPreference,
45-
source: google.maps.StreetViewSource.OUTDOOR,
45+
source: google.maps.StreetViewSource.DEFAULT,
4646
radius: config.svRequest.radius,
4747
};
4848

49-
let retries = 50;
49+
let remainingRetries = config.svRequest.maxRetries;
5050
/* eslint-disable @typescript-eslint/no-non-null-assertion */
5151
const map = MAPS.get(game.mapId)!;
5252

5353
try {
5454
while (true) {
55-
retries--;
55+
remainingRetries--;
5656
let data: google.maps.StreetViewPanoramaData | null = null;
5757
const randomLocation = randomPointInMap(map.properties.bb, map.geometry);
5858

@@ -64,7 +64,7 @@ export const getRandomStreetView = createAsyncThunk<
6464

6565
data = svData;
6666
} catch (err) {
67-
if (!retries) {
67+
if (!remainingRetries) {
6868
throw err;
6969
} else {
7070
warn(`Unable to find random Street View`);

tests/integration/play-game.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ describe('Integration, game play', () => {
5252
screen.getByRole('button', {name: /getting a random street view/i})
5353
).toBeDisabled();
5454

55-
await waitFor(() => expect(getPanoramSpy).toHaveBeenCalledTimes(50));
55+
await waitFor(() => expect(getPanoramSpy).toHaveBeenCalledTimes(80));
5656
const alertDialog = screen.getByRole('alert');
5757
expect(
5858
within(alertDialog).getByText(/no results found/i)
@@ -76,7 +76,7 @@ describe('Integration, game play', () => {
7676
expect(screen.getAllByRole('heading')).toMatchSnapshot(
7777
'intermission screen'
7878
);
79-
expect(getPanoramSpy).toHaveBeenCalledTimes(51);
79+
expect(getPanoramSpy).toHaveBeenCalledTimes(81);
8080
});
8181

8282
it('round 1 works with user interaction', async () => {

0 commit comments

Comments
 (0)