4
4
* SPDX-License-Identifier: Apache-2.0
5
5
*/
6
6
7
- import { FakeLatLngBounds } from './fake_lat_lng.js' ;
7
+ import { FakeLatLng , FakeLatLngBounds } from './fake_lat_lng.js' ;
8
8
9
9
type DirectionsRoute = google . maps . DirectionsRoute ;
10
+ type DirectionsLeg = google . maps . DirectionsLeg ;
10
11
11
12
const EMPTY_FAKE_ROUTE : DirectionsRoute = {
12
13
bounds : new FakeLatLngBounds ( ) ,
@@ -19,6 +20,16 @@ const EMPTY_FAKE_ROUTE: DirectionsRoute = {
19
20
waypoint_order : [ ] ,
20
21
} ;
21
22
23
+ const EMPTY_FAKE_LEG : DirectionsLeg = {
24
+ end_address : '' ,
25
+ end_location : new FakeLatLng ( 0 , 0 ) ,
26
+ start_address : '' ,
27
+ start_location : new FakeLatLng ( 0 , 0 ) ,
28
+ steps : [ ] ,
29
+ traffic_speed_entry : [ ] ,
30
+ via_waypoints : [ ] ,
31
+ } ;
32
+
22
33
/**
23
34
* Makes a fake `google.maps.DirectionsRoute` object for testing purposes.
24
35
*
@@ -28,5 +39,17 @@ const EMPTY_FAKE_ROUTE: DirectionsRoute = {
28
39
*/
29
40
export function makeFakeRoute ( fields : Partial < DirectionsRoute > = { } ) :
30
41
DirectionsRoute {
31
- return { ...EMPTY_FAKE_ROUTE , ...fields } ;
32
- }
42
+ return { ...EMPTY_FAKE_ROUTE , ...fields } ;
43
+ }
44
+
45
+ /**
46
+ * Makes a fake `google.maps.DirectionsLeg` object for testing purposes.
47
+ *
48
+ * @param fields - An object of fields of the `DirectionsLeg`. Any fields not
49
+ * provided will default to empty strings, empty arrays, or the LatLng
50
+ * (0, 0).
51
+ */
52
+ export function makeFakeLeg ( fields : Partial < DirectionsLeg > = { } ) :
53
+ DirectionsLeg {
54
+ return { ...EMPTY_FAKE_LEG , ...fields } ;
55
+ }
0 commit comments