From 4f6e7c11e4c882801bc4076ed9d0ae9f1862acc5 Mon Sep 17 00:00:00 2001 From: Michael Reinhard Date: Fri, 21 Jul 2023 14:56:51 -0700 Subject: [PATCH] internal PiperOrigin-RevId: 550057644 --- src/testing/fake_route.ts | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/src/testing/fake_route.ts b/src/testing/fake_route.ts index 1f18206..39d32e1 100644 --- a/src/testing/fake_route.ts +++ b/src/testing/fake_route.ts @@ -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(), @@ -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. * @@ -28,5 +39,17 @@ const EMPTY_FAKE_ROUTE: DirectionsRoute = { */ export function makeFakeRoute(fields: Partial = {}): 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 { + return {...EMPTY_FAKE_LEG, ...fields}; + }