Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

internal #68

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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};
}