Skip to content

Commit

Permalink
internal
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 550057644
  • Loading branch information
mcreinhard authored and copybara-github committed Jul 21, 2023
1 parent 30b3aa1 commit 4f6e7c1
Showing 1 changed file with 26 additions and 3 deletions.
29 changes: 26 additions & 3 deletions src/testing/fake_route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
* SPDX-License-Identifier: Apache-2.0
*/

import {FakeLatLngBounds} from './fake_lat_lng.js';
import {FakeLatLng, FakeLatLngBounds} from './fake_lat_lng.js';

type DirectionsRoute = google.maps.DirectionsRoute;
type DirectionsLeg = google.maps.DirectionsLeg;

const EMPTY_FAKE_ROUTE: DirectionsRoute = {
bounds: new FakeLatLngBounds(),
Expand All @@ -19,6 +20,16 @@ const EMPTY_FAKE_ROUTE: DirectionsRoute = {
waypoint_order: [],
};

const EMPTY_FAKE_LEG: DirectionsLeg = {
end_address: '',
end_location: new FakeLatLng(0, 0),
start_address: '',
start_location: new FakeLatLng(0, 0),
steps: [],
traffic_speed_entry: [],
via_waypoints: [],
};

/**
* Makes a fake `google.maps.DirectionsRoute` object for testing purposes.
*
Expand All @@ -28,5 +39,17 @@ const EMPTY_FAKE_ROUTE: DirectionsRoute = {
*/
export function makeFakeRoute(fields: Partial<DirectionsRoute> = {}):
DirectionsRoute {
return {...EMPTY_FAKE_ROUTE, ...fields};
}
return {...EMPTY_FAKE_ROUTE, ...fields};
}

/**
* Makes a fake `google.maps.DirectionsLeg` object for testing purposes.
*
* @param fields - An object of fields of the `DirectionsLeg`. Any fields not
* provided will default to empty strings, empty arrays, or the LatLng
* (0, 0).
*/
export function makeFakeLeg(fields: Partial<DirectionsLeg> = {}):
DirectionsLeg {
return {...EMPTY_FAKE_LEG, ...fields};
}

0 comments on commit 4f6e7c1

Please sign in to comment.