@opentripplanner/core-utils 14.0.0-alpha.2 → 14.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -4
- package/esm/itinerary.js +70 -32
- package/esm/itinerary.js.map +1 -1
- package/esm/otpSchema.json +7321 -5821
- package/esm/planQuery.graphql +12 -0
- package/esm/profile.js +1 -1
- package/esm/profile.js.map +1 -1
- package/esm/query-gen.js +2 -2
- package/esm/query-gen.js.map +1 -1
- package/esm/query.js +2 -5
- package/esm/query.js.map +1 -1
- package/esm/storage.js +2 -6
- package/esm/storage.js.map +1 -1
- package/esm/time.js +1 -2
- package/esm/time.js.map +1 -1
- package/lib/index.js +50 -35
- package/lib/index.js.map +1 -1
- package/lib/itinerary.d.ts +25 -8
- package/lib/itinerary.d.ts.map +1 -1
- package/lib/itinerary.js +524 -495
- package/lib/itinerary.js.map +1 -1
- package/lib/map.js +40 -39
- package/lib/map.js.map +1 -1
- package/lib/otpSchema.json +7321 -5821
- package/lib/planQuery.graphql +12 -0
- package/lib/profile.js +1 -1
- package/lib/profile.js.map +1 -1
- package/lib/query-gen.js +134 -138
- package/lib/query-gen.js.map +1 -1
- package/lib/query.js +3 -6
- package/lib/query.js.map +1 -1
- package/lib/route.js +230 -248
- package/lib/route.js.map +1 -1
- package/lib/storage.d.ts.map +1 -1
- package/lib/storage.js +22 -28
- package/lib/storage.js.map +1 -1
- package/lib/suspense.js +28 -16
- package/lib/suspense.js.map +1 -1
- package/lib/time.js +36 -49
- package/lib/time.js.map +1 -1
- package/lib/ui.js +33 -36
- package/lib/ui.js.map +1 -1
- package/package.json +3 -3
- package/src/__tests__/__snapshots__/query-params.ts.snap +201 -201
- package/src/__tests__/__snapshots__/query.js.snap +28 -28
- package/src/__tests__/__snapshots__/route.js.snap +76 -76
- package/src/__tests__/__snapshots__/time.js.snap +2 -2
- package/src/__tests__/itinerary.ts +108 -23
- package/src/__tests__/query.js +1 -1
- package/src/__tests__/route.js +1 -1
- package/src/core-utils.story.tsx +34 -23
- package/src/itinerary.ts +85 -37
- package/src/otpSchema.json +7321 -5821
- package/src/planQuery.graphql +12 -0
- package/src/profile.js +1 -1
- package/src/query-gen.ts +1 -1
- package/src/query.js +2 -5
- package/src/storage.ts +5 -9
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
// Jest Snapshot v1, https://
|
|
1
|
+
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
|
|
2
2
|
|
|
3
3
|
exports[`util > route routeComparator should prioritize OTP1 routes with valid sortOrder 1`] = `
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
[
|
|
5
|
+
{
|
|
6
6
|
"agencyId": "bcd",
|
|
7
7
|
"longName": "Around town",
|
|
8
8
|
"mode": "BUS",
|
|
9
9
|
"shortName": "20",
|
|
10
10
|
"sortOrder": 2,
|
|
11
11
|
},
|
|
12
|
-
|
|
12
|
+
{
|
|
13
13
|
"agencyId": "bcd",
|
|
14
14
|
"longName": "Around another town",
|
|
15
15
|
"shortName": "3",
|
|
@@ -20,20 +20,20 @@ Array [
|
|
|
20
20
|
`;
|
|
21
21
|
|
|
22
22
|
exports[`util > route routeComparator should prioritize OTP2 routes with valid sortOrder 1`] = `
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
[
|
|
24
|
+
{
|
|
25
25
|
"longName": "Loop route",
|
|
26
26
|
"mode": "BUS",
|
|
27
27
|
"shortName": "2",
|
|
28
28
|
"sortOrder": -999,
|
|
29
29
|
},
|
|
30
|
-
|
|
30
|
+
{
|
|
31
31
|
"longName": "Across town",
|
|
32
32
|
"mode": "BUS",
|
|
33
33
|
"shortName": "10",
|
|
34
34
|
"sortOrder": 10,
|
|
35
35
|
},
|
|
36
|
-
|
|
36
|
+
{
|
|
37
37
|
"longName": "Around another town",
|
|
38
38
|
"shortName": "3",
|
|
39
39
|
"sortOrder": null,
|
|
@@ -43,15 +43,15 @@ Array [
|
|
|
43
43
|
`;
|
|
44
44
|
|
|
45
45
|
exports[`util > route routeComparator should prioritize routes with alphabetic shortNames over integer shortNames 1`] = `
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
[
|
|
47
|
+
{
|
|
48
48
|
"agencyId": "bcd",
|
|
49
49
|
"longName": "A-line",
|
|
50
50
|
"mode": "BUS",
|
|
51
51
|
"shortName": "A",
|
|
52
52
|
"sortOrder": -999,
|
|
53
53
|
},
|
|
54
|
-
|
|
54
|
+
{
|
|
55
55
|
"agencyId": "bcd",
|
|
56
56
|
"longName": "Loop route",
|
|
57
57
|
"mode": "BUS",
|
|
@@ -62,15 +62,15 @@ Array [
|
|
|
62
62
|
`;
|
|
63
63
|
|
|
64
64
|
exports[`util > route routeComparator should prioritize routes with shortNames over those with just longNames 1`] = `
|
|
65
|
-
|
|
66
|
-
|
|
65
|
+
[
|
|
66
|
+
{
|
|
67
67
|
"agencyId": "bcd",
|
|
68
68
|
"longName": "B-line",
|
|
69
69
|
"mode": "BUS",
|
|
70
70
|
"shortName": "B",
|
|
71
71
|
"sortOrder": -999,
|
|
72
72
|
},
|
|
73
|
-
|
|
73
|
+
{
|
|
74
74
|
"agencyId": "bcd",
|
|
75
75
|
"longName": "A meandering route",
|
|
76
76
|
"mode": "BUS",
|
|
@@ -80,8 +80,8 @@ Array [
|
|
|
80
80
|
`;
|
|
81
81
|
|
|
82
82
|
exports[`util > route routeComparator should sort OTP1 routes on all of the criteria at once 1`] = `
|
|
83
|
-
|
|
84
|
-
|
|
83
|
+
[
|
|
84
|
+
{
|
|
85
85
|
"agencyId": "abc",
|
|
86
86
|
"agencyName": "Acclaimed agency 1",
|
|
87
87
|
"longName": "Express route X",
|
|
@@ -90,7 +90,7 @@ Array [
|
|
|
90
90
|
"shortName": "30X",
|
|
91
91
|
"sortOrder": 10,
|
|
92
92
|
},
|
|
93
|
-
|
|
93
|
+
{
|
|
94
94
|
"agencyId": "abc",
|
|
95
95
|
"agencyName": "Agency 1",
|
|
96
96
|
"longName": "Intercity Train 2",
|
|
@@ -99,104 +99,104 @@ Array [
|
|
|
99
99
|
"shortName": "IC",
|
|
100
100
|
"sortOrder": 10,
|
|
101
101
|
},
|
|
102
|
-
|
|
102
|
+
{
|
|
103
103
|
"agencyId": "bcd",
|
|
104
104
|
"longName": "Yellow line Subway",
|
|
105
105
|
"mode": "SUBWAY",
|
|
106
106
|
"shortName": "Yellow",
|
|
107
107
|
"sortOrder": 2,
|
|
108
108
|
},
|
|
109
|
-
|
|
109
|
+
{
|
|
110
110
|
"agencyId": "bcd",
|
|
111
111
|
"longName": "Intercity Train",
|
|
112
112
|
"mode": "RAIL",
|
|
113
113
|
"shortName": "IC",
|
|
114
114
|
"sortOrder": 2,
|
|
115
115
|
},
|
|
116
|
-
|
|
116
|
+
{
|
|
117
117
|
"agencyId": "bcd",
|
|
118
118
|
"longName": "Local route",
|
|
119
119
|
"mode": "BUS",
|
|
120
120
|
"shortName": "6",
|
|
121
121
|
"sortOrder": 2,
|
|
122
122
|
},
|
|
123
|
-
|
|
123
|
+
{
|
|
124
124
|
"agencyId": "bcd",
|
|
125
125
|
"longName": "Around town",
|
|
126
126
|
"mode": "BUS",
|
|
127
127
|
"shortName": "20",
|
|
128
128
|
"sortOrder": 2,
|
|
129
129
|
},
|
|
130
|
-
|
|
130
|
+
{
|
|
131
131
|
"agencyId": "bcd",
|
|
132
132
|
"longName": "Express route",
|
|
133
133
|
"mode": "BUS",
|
|
134
134
|
"shortName": "30",
|
|
135
135
|
"sortOrder": 2,
|
|
136
136
|
},
|
|
137
|
-
|
|
137
|
+
{
|
|
138
138
|
"agencyId": "bcd",
|
|
139
139
|
"longName": "Variation of express route",
|
|
140
140
|
"mode": "BUS",
|
|
141
141
|
"shortName": "30",
|
|
142
142
|
"sortOrder": 2,
|
|
143
143
|
},
|
|
144
|
-
|
|
144
|
+
{
|
|
145
145
|
"agencyId": "bcd",
|
|
146
146
|
"longName": "Zig-zagging route",
|
|
147
147
|
"mode": "BUS",
|
|
148
148
|
"shortName": "30",
|
|
149
149
|
"sortOrder": 2,
|
|
150
150
|
},
|
|
151
|
-
|
|
151
|
+
{
|
|
152
152
|
"agencyId": "bcd",
|
|
153
153
|
"longName": "Xpress route C",
|
|
154
154
|
"mode": "BUS",
|
|
155
155
|
"shortName": "30C",
|
|
156
156
|
"sortOrder": 2,
|
|
157
157
|
},
|
|
158
|
-
|
|
158
|
+
{
|
|
159
159
|
"agencyId": "bcd",
|
|
160
160
|
"longName": "Across town",
|
|
161
161
|
"mode": "BUS",
|
|
162
162
|
"shortName": "10",
|
|
163
163
|
"sortOrder": 10,
|
|
164
164
|
},
|
|
165
|
-
|
|
165
|
+
{
|
|
166
166
|
"agencyId": "bcd",
|
|
167
167
|
"longName": "A-line",
|
|
168
168
|
"mode": "BUS",
|
|
169
169
|
"shortName": "A",
|
|
170
170
|
"sortOrder": -999,
|
|
171
171
|
},
|
|
172
|
-
|
|
172
|
+
{
|
|
173
173
|
"agencyId": "bcd",
|
|
174
174
|
"longName": "B-line",
|
|
175
175
|
"mode": "BUS",
|
|
176
176
|
"shortName": "B",
|
|
177
177
|
"sortOrder": -999,
|
|
178
178
|
},
|
|
179
|
-
|
|
179
|
+
{
|
|
180
180
|
"agencyId": "bcd",
|
|
181
181
|
"longName": "Loop route",
|
|
182
182
|
"mode": "BUS",
|
|
183
183
|
"shortName": "2",
|
|
184
184
|
"sortOrder": -999,
|
|
185
185
|
},
|
|
186
|
-
|
|
186
|
+
{
|
|
187
187
|
"agencyId": "bcd",
|
|
188
188
|
"longName": "Around another town",
|
|
189
189
|
"shortName": "3",
|
|
190
190
|
"sortOrder": -999,
|
|
191
191
|
"type": 3,
|
|
192
192
|
},
|
|
193
|
-
|
|
193
|
+
{
|
|
194
194
|
"agencyId": "bcd",
|
|
195
195
|
"longName": "Express route X",
|
|
196
196
|
"mode": "BUS",
|
|
197
197
|
"shortName": "30X",
|
|
198
198
|
},
|
|
199
|
-
|
|
199
|
+
{
|
|
200
200
|
"agencyId": "bcd",
|
|
201
201
|
"longName": "A meandering route",
|
|
202
202
|
"mode": "BUS",
|
|
@@ -206,9 +206,9 @@ Array [
|
|
|
206
206
|
`;
|
|
207
207
|
|
|
208
208
|
exports[`util > route routeComparator should sort OTP2 routes on all of the criteria at once 1`] = `
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
"agency":
|
|
209
|
+
[
|
|
210
|
+
{
|
|
211
|
+
"agency": {
|
|
212
212
|
"id": "abc",
|
|
213
213
|
"name": "Acclaimed agency 1",
|
|
214
214
|
},
|
|
@@ -218,8 +218,8 @@ Array [
|
|
|
218
218
|
"shortName": "30X",
|
|
219
219
|
"sortOrder": 2,
|
|
220
220
|
},
|
|
221
|
-
|
|
222
|
-
"agency":
|
|
221
|
+
{
|
|
222
|
+
"agency": {
|
|
223
223
|
"id": "abc",
|
|
224
224
|
"name": "Agency 1",
|
|
225
225
|
},
|
|
@@ -229,90 +229,90 @@ Array [
|
|
|
229
229
|
"shortName": "IC",
|
|
230
230
|
"sortOrder": 2,
|
|
231
231
|
},
|
|
232
|
-
|
|
232
|
+
{
|
|
233
233
|
"longName": "A-line",
|
|
234
234
|
"mode": "BUS",
|
|
235
235
|
"shortName": "A",
|
|
236
236
|
"sortOrder": -999,
|
|
237
237
|
},
|
|
238
|
-
|
|
238
|
+
{
|
|
239
239
|
"longName": "Loop route",
|
|
240
240
|
"mode": "BUS",
|
|
241
241
|
"shortName": "2",
|
|
242
242
|
"sortOrder": -999,
|
|
243
243
|
},
|
|
244
|
-
|
|
244
|
+
{
|
|
245
245
|
"longName": "Yellow line Subway",
|
|
246
246
|
"mode": "SUBWAY",
|
|
247
247
|
"shortName": "Yellow",
|
|
248
248
|
"sortOrder": 2,
|
|
249
249
|
},
|
|
250
|
-
|
|
250
|
+
{
|
|
251
251
|
"longName": "Intercity Train",
|
|
252
252
|
"mode": "RAIL",
|
|
253
253
|
"shortName": "IC",
|
|
254
254
|
"sortOrder": 2,
|
|
255
255
|
},
|
|
256
|
-
|
|
256
|
+
{
|
|
257
257
|
"longName": "Local route",
|
|
258
258
|
"mode": "BUS",
|
|
259
259
|
"shortName": "6",
|
|
260
260
|
"sortOrder": 2,
|
|
261
261
|
},
|
|
262
|
-
|
|
262
|
+
{
|
|
263
263
|
"longName": "Around town",
|
|
264
264
|
"mode": "BUS",
|
|
265
265
|
"shortName": "20",
|
|
266
266
|
"sortOrder": 2,
|
|
267
267
|
},
|
|
268
|
-
|
|
268
|
+
{
|
|
269
269
|
"longName": "Express route",
|
|
270
270
|
"mode": "BUS",
|
|
271
271
|
"shortName": "30",
|
|
272
272
|
"sortOrder": 2,
|
|
273
273
|
},
|
|
274
|
-
|
|
274
|
+
{
|
|
275
275
|
"longName": "Variation of express route",
|
|
276
276
|
"mode": "BUS",
|
|
277
277
|
"shortName": "30",
|
|
278
278
|
"sortOrder": 2,
|
|
279
279
|
},
|
|
280
|
-
|
|
280
|
+
{
|
|
281
281
|
"longName": "Zig-zagging route",
|
|
282
282
|
"mode": "BUS",
|
|
283
283
|
"shortName": "30",
|
|
284
284
|
"sortOrder": 2,
|
|
285
285
|
},
|
|
286
|
-
|
|
286
|
+
{
|
|
287
287
|
"longName": "Xpress route C",
|
|
288
288
|
"mode": "BUS",
|
|
289
289
|
"shortName": "30C",
|
|
290
290
|
"sortOrder": 2,
|
|
291
291
|
},
|
|
292
|
-
|
|
292
|
+
{
|
|
293
293
|
"longName": "Express route X",
|
|
294
294
|
"mode": "BUS",
|
|
295
295
|
"shortName": "30X",
|
|
296
296
|
"sortOrder": 2,
|
|
297
297
|
},
|
|
298
|
-
|
|
298
|
+
{
|
|
299
299
|
"longName": "Across town",
|
|
300
300
|
"mode": "BUS",
|
|
301
301
|
"shortName": "10",
|
|
302
302
|
"sortOrder": 10,
|
|
303
303
|
},
|
|
304
|
-
|
|
304
|
+
{
|
|
305
305
|
"longName": "B-line",
|
|
306
306
|
"mode": "BUS",
|
|
307
307
|
"shortName": "B",
|
|
308
308
|
},
|
|
309
|
-
|
|
309
|
+
{
|
|
310
310
|
"longName": "Around another town",
|
|
311
311
|
"shortName": "3",
|
|
312
312
|
"sortOrder": null,
|
|
313
313
|
"type": 3,
|
|
314
314
|
},
|
|
315
|
-
|
|
315
|
+
{
|
|
316
316
|
"longName": "A meandering route",
|
|
317
317
|
"mode": "BUS",
|
|
318
318
|
},
|
|
@@ -320,15 +320,15 @@ Array [
|
|
|
320
320
|
`;
|
|
321
321
|
|
|
322
322
|
exports[`util > route routeComparator should sort based off of route type 1`] = `
|
|
323
|
-
|
|
324
|
-
|
|
323
|
+
[
|
|
324
|
+
{
|
|
325
325
|
"agencyId": "bcd",
|
|
326
326
|
"longName": "Yellow line Subway",
|
|
327
327
|
"mode": "SUBWAY",
|
|
328
328
|
"shortName": "Yellow",
|
|
329
329
|
"sortOrder": 2,
|
|
330
330
|
},
|
|
331
|
-
|
|
331
|
+
{
|
|
332
332
|
"agencyId": "bcd",
|
|
333
333
|
"longName": "Intercity Train",
|
|
334
334
|
"mode": "RAIL",
|
|
@@ -339,8 +339,8 @@ Array [
|
|
|
339
339
|
`;
|
|
340
340
|
|
|
341
341
|
exports[`util > route routeComparator should sort routes based off of agencyName if no transitOperators are defined 1`] = `
|
|
342
|
-
|
|
343
|
-
|
|
342
|
+
[
|
|
343
|
+
{
|
|
344
344
|
"agencyId": "abc",
|
|
345
345
|
"agencyName": "Acclaimed agency 1",
|
|
346
346
|
"longName": "Express route X",
|
|
@@ -349,7 +349,7 @@ Array [
|
|
|
349
349
|
"shortName": "30X",
|
|
350
350
|
"sortOrder": 10,
|
|
351
351
|
},
|
|
352
|
-
|
|
352
|
+
{
|
|
353
353
|
"agencyId": "abc",
|
|
354
354
|
"agencyName": "Agency 1",
|
|
355
355
|
"longName": "Intercity Train 2",
|
|
@@ -362,15 +362,15 @@ Array [
|
|
|
362
362
|
`;
|
|
363
363
|
|
|
364
364
|
exports[`util > route routeComparator should sort routes based off of integer shortName 1`] = `
|
|
365
|
-
|
|
366
|
-
|
|
365
|
+
[
|
|
366
|
+
{
|
|
367
367
|
"agencyId": "bcd",
|
|
368
368
|
"longName": "Loop route",
|
|
369
369
|
"mode": "BUS",
|
|
370
370
|
"shortName": "2",
|
|
371
371
|
"sortOrder": -999,
|
|
372
372
|
},
|
|
373
|
-
|
|
373
|
+
{
|
|
374
374
|
"agencyId": "bcd",
|
|
375
375
|
"longName": "Around another town",
|
|
376
376
|
"shortName": "3",
|
|
@@ -381,15 +381,15 @@ Array [
|
|
|
381
381
|
`;
|
|
382
382
|
|
|
383
383
|
exports[`util > route routeComparator should sort routes based off of longNames 1`] = `
|
|
384
|
-
|
|
385
|
-
|
|
384
|
+
[
|
|
385
|
+
{
|
|
386
386
|
"agencyId": "bcd",
|
|
387
387
|
"longName": "Express route",
|
|
388
388
|
"mode": "BUS",
|
|
389
389
|
"shortName": "30",
|
|
390
390
|
"sortOrder": 2,
|
|
391
391
|
},
|
|
392
|
-
|
|
392
|
+
{
|
|
393
393
|
"agencyId": "bcd",
|
|
394
394
|
"longName": "Variation of express route",
|
|
395
395
|
"mode": "BUS",
|
|
@@ -400,15 +400,15 @@ Array [
|
|
|
400
400
|
`;
|
|
401
401
|
|
|
402
402
|
exports[`util > route routeComparator should sort routes based off of shortNames 1`] = `
|
|
403
|
-
|
|
404
|
-
|
|
403
|
+
[
|
|
404
|
+
{
|
|
405
405
|
"agencyId": "bcd",
|
|
406
406
|
"longName": "A-line",
|
|
407
407
|
"mode": "BUS",
|
|
408
408
|
"shortName": "A",
|
|
409
409
|
"sortOrder": -999,
|
|
410
410
|
},
|
|
411
|
-
|
|
411
|
+
{
|
|
412
412
|
"agencyId": "bcd",
|
|
413
413
|
"longName": "B-line",
|
|
414
414
|
"mode": "BUS",
|
|
@@ -419,15 +419,15 @@ Array [
|
|
|
419
419
|
`;
|
|
420
420
|
|
|
421
421
|
exports[`util > route routeComparator should sort routes based off of sortOrder 1`] = `
|
|
422
|
-
|
|
423
|
-
|
|
422
|
+
[
|
|
423
|
+
{
|
|
424
424
|
"agencyId": "bcd",
|
|
425
425
|
"longName": "Around town",
|
|
426
426
|
"mode": "BUS",
|
|
427
427
|
"shortName": "20",
|
|
428
428
|
"sortOrder": 2,
|
|
429
429
|
},
|
|
430
|
-
|
|
430
|
+
{
|
|
431
431
|
"agencyId": "bcd",
|
|
432
432
|
"longName": "Across town",
|
|
433
433
|
"mode": "BUS",
|
|
@@ -438,8 +438,8 @@ Array [
|
|
|
438
438
|
`;
|
|
439
439
|
|
|
440
440
|
exports[`util > route routeComparator should sort routes based off of transitOperators sort value when a match is found 1`] = `
|
|
441
|
-
|
|
442
|
-
|
|
441
|
+
[
|
|
442
|
+
{
|
|
443
443
|
"agencyId": "abc",
|
|
444
444
|
"agencyName": "Agency 1",
|
|
445
445
|
"longName": "Intercity Train 2",
|
|
@@ -448,7 +448,7 @@ Array [
|
|
|
448
448
|
"shortName": "IC",
|
|
449
449
|
"sortOrder": 10,
|
|
450
450
|
},
|
|
451
|
-
|
|
451
|
+
{
|
|
452
452
|
"agencyId": "abc",
|
|
453
453
|
"agencyName": "Acclaimed agency 1",
|
|
454
454
|
"longName": "Express route X",
|
|
@@ -461,15 +461,15 @@ Array [
|
|
|
461
461
|
`;
|
|
462
462
|
|
|
463
463
|
exports[`util > route routeComparator should sort routes with alphanumeric shortNames 1`] = `
|
|
464
|
-
|
|
465
|
-
|
|
464
|
+
[
|
|
465
|
+
{
|
|
466
466
|
"agencyId": "bcd",
|
|
467
467
|
"longName": "Xpress route C",
|
|
468
468
|
"mode": "BUS",
|
|
469
469
|
"shortName": "30C",
|
|
470
470
|
"sortOrder": 2,
|
|
471
471
|
},
|
|
472
|
-
|
|
472
|
+
{
|
|
473
473
|
"agencyId": "bcd",
|
|
474
474
|
"longName": "Express route X",
|
|
475
475
|
"mode": "BUS",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Jest Snapshot v1, https://
|
|
1
|
+
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
|
|
2
2
|
|
|
3
3
|
exports[`time getCurrentDate should return current date at specified timezone 1`] = `"2019-08-04"`;
|
|
4
4
|
|
|
@@ -13,7 +13,7 @@ exports[`time getUserTimezone should get the correct timezone from the testing e
|
|
|
13
13
|
exports[`time time format functions should correctly format 9401 seconds as a duration since midnight 1`] = `"02:36"`;
|
|
14
14
|
|
|
15
15
|
exports[`time toHoursMinutesSeconds should correctly break down 9401 in hours, minutes, and seconds 1`] = `
|
|
16
|
-
|
|
16
|
+
{
|
|
17
17
|
"hours": 2,
|
|
18
18
|
"minutes": 36,
|
|
19
19
|
"seconds": 41,
|
|
@@ -14,10 +14,13 @@ import {
|
|
|
14
14
|
mapOldElevationComponentToNew
|
|
15
15
|
} from "../itinerary";
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
import bikeRentalItinerary from "./__mocks__/bike-rental-itinerary.json";
|
|
18
|
+
import tncItinerary from "./__mocks__/tnc-itinerary.json";
|
|
19
|
+
import fareProductItinerary from "./__mocks__/fare-products-itinerary.json";
|
|
20
|
+
import flexItinerary from "../../../itinerary-body/src/__mocks__/itineraries/flex-itinerary.json";
|
|
21
|
+
import faresv2Itinerary from "../../../itinerary-body/src/__mocks__/itineraries/fares-v2-fare-components.json";
|
|
22
|
+
|
|
23
|
+
global.structuredClone = val => JSON.parse(JSON.stringify(val));
|
|
21
24
|
|
|
22
25
|
const basePlace = {
|
|
23
26
|
lat: 0,
|
|
@@ -129,37 +132,100 @@ describe("util > itinerary", () => {
|
|
|
129
132
|
});
|
|
130
133
|
|
|
131
134
|
describe("getLegCost", () => {
|
|
135
|
+
const freeLeg = {
|
|
136
|
+
fareProducts: [
|
|
137
|
+
{
|
|
138
|
+
id: "testId",
|
|
139
|
+
product: {
|
|
140
|
+
medium: null,
|
|
141
|
+
name: "rideCost",
|
|
142
|
+
price: { amount: 0, currency: "USD" },
|
|
143
|
+
riderCategory: null
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
]
|
|
147
|
+
};
|
|
132
148
|
const leg = {
|
|
133
149
|
fareProducts: [
|
|
134
150
|
{
|
|
135
151
|
id: "testId",
|
|
136
152
|
product: {
|
|
137
|
-
medium:
|
|
153
|
+
medium: null,
|
|
138
154
|
name: "rideCost",
|
|
139
155
|
price: { amount: 200, currency: "USD" },
|
|
140
|
-
riderCategory:
|
|
156
|
+
riderCategory: null
|
|
141
157
|
}
|
|
142
158
|
},
|
|
143
159
|
{
|
|
144
160
|
id: "testId",
|
|
145
161
|
product: {
|
|
146
|
-
medium:
|
|
147
|
-
name: "transfer",
|
|
162
|
+
medium: null,
|
|
163
|
+
name: "transfer-from-other-vehicle",
|
|
148
164
|
price: { amount: 50, currency: "USD" },
|
|
149
|
-
riderCategory:
|
|
165
|
+
riderCategory: null
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
]
|
|
169
|
+
};
|
|
170
|
+
const complicatedLeg = {
|
|
171
|
+
fareProducts: [
|
|
172
|
+
{
|
|
173
|
+
id: "testId",
|
|
174
|
+
product: {
|
|
175
|
+
medium: { id: "agency:cash" },
|
|
176
|
+
name: "transfer-from-other-vehicle",
|
|
177
|
+
price: { amount: 50, currency: "USD" },
|
|
178
|
+
riderCategory: { id: "agency:child" }
|
|
179
|
+
}
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
id: "testId",
|
|
183
|
+
product: {
|
|
184
|
+
medium: "cash",
|
|
185
|
+
name: "rideCost",
|
|
186
|
+
price: { amount: 200, currency: "USD" },
|
|
187
|
+
riderCategory: "adult"
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
]
|
|
191
|
+
};
|
|
192
|
+
const halfLeg = {
|
|
193
|
+
fareProducts: [
|
|
194
|
+
{
|
|
195
|
+
id: "testId",
|
|
196
|
+
product: {
|
|
197
|
+
medium: { id: "agency:cash" },
|
|
198
|
+
name: "rideCost",
|
|
199
|
+
price: { amount: 30, currency: "USD" },
|
|
200
|
+
riderCategory: null
|
|
201
|
+
}
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
id: "testId2",
|
|
205
|
+
product: {
|
|
206
|
+
medium: { id: "agency:digital" },
|
|
207
|
+
name: "rideCost",
|
|
208
|
+
price: { amount: 20, currency: "USD" },
|
|
209
|
+
riderCategory: null
|
|
150
210
|
}
|
|
151
211
|
}
|
|
152
212
|
]
|
|
153
213
|
};
|
|
154
214
|
it("should return the total cost for a leg", () => {
|
|
155
|
-
const result = getLegCost(leg,
|
|
156
|
-
expect(result.price).toEqual({ amount:
|
|
215
|
+
const result = getLegCost(leg, null, null);
|
|
216
|
+
expect(result.price).toEqual({ amount: 50, currency: "USD" });
|
|
157
217
|
});
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
218
|
+
it("should return the 0 cost for a free leg", () => {
|
|
219
|
+
const result = getLegCost(freeLeg, null, null);
|
|
220
|
+
expect(result.price).toEqual({ amount: 0, currency: "USD" });
|
|
221
|
+
});
|
|
222
|
+
it("should return the correct cost for a leg with multiple types of fares", () => {
|
|
223
|
+
const result = getLegCost(complicatedLeg, "cash", "child");
|
|
224
|
+
expect(result.price).toEqual({ amount: 50, currency: "USD" });
|
|
225
|
+
});
|
|
226
|
+
it("should return the correct cost for a leg with no rider category", () => {
|
|
227
|
+
const result = getLegCost(halfLeg, "cash", null);
|
|
228
|
+
expect(result.price).toEqual({ amount: 30, currency: "USD" });
|
|
163
229
|
});
|
|
164
230
|
|
|
165
231
|
it("should return undefined if no fare products exist on the leg", () => {
|
|
@@ -177,8 +243,8 @@ describe("util > itinerary", () => {
|
|
|
177
243
|
it("should calculate the total cost of an itinerary", () => {
|
|
178
244
|
const result = getItineraryCost(
|
|
179
245
|
fareProductItinerary.legs,
|
|
180
|
-
"
|
|
181
|
-
"
|
|
246
|
+
"cash",
|
|
247
|
+
"regular"
|
|
182
248
|
);
|
|
183
249
|
expect(result.amount).toEqual(5.75);
|
|
184
250
|
expect(result.currency).toEqual({
|
|
@@ -186,6 +252,29 @@ describe("util > itinerary", () => {
|
|
|
186
252
|
digits: 2
|
|
187
253
|
});
|
|
188
254
|
});
|
|
255
|
+
it("should calculate the total cost of an itinerary using fares v2", () => {
|
|
256
|
+
const result = getItineraryCost(faresv2Itinerary.legs, "3", "ADULT");
|
|
257
|
+
expect(result.amount).toEqual(2.8);
|
|
258
|
+
});
|
|
259
|
+
it("should calculate the individual leg cost of a fares v2 legs", () => {
|
|
260
|
+
const firstLegResult = getLegCost(faresv2Itinerary.legs[1], "3", "ADULT");
|
|
261
|
+
expect(firstLegResult.price?.amount).toEqual(2);
|
|
262
|
+
|
|
263
|
+
const secondLegResult = getLegCost(
|
|
264
|
+
faresv2Itinerary.legs[3],
|
|
265
|
+
"3",
|
|
266
|
+
"ADULT"
|
|
267
|
+
);
|
|
268
|
+
expect(secondLegResult.price?.amount).toEqual(0.8);
|
|
269
|
+
|
|
270
|
+
// Check for alternate product
|
|
271
|
+
expect(firstLegResult.alternateFareProducts?.[0]?.price?.amount).toEqual(
|
|
272
|
+
undefined
|
|
273
|
+
);
|
|
274
|
+
expect(secondLegResult.alternateFareProducts?.[0]?.price?.amount).toEqual(
|
|
275
|
+
2.8
|
|
276
|
+
);
|
|
277
|
+
});
|
|
189
278
|
it("should calculate the total cost of an itinerary will null ids", () => {
|
|
190
279
|
const result = getItineraryCost(fareProductItinerary.legs, null, null);
|
|
191
280
|
expect(result.amount).toEqual(2.75);
|
|
@@ -206,11 +295,7 @@ describe("util > itinerary", () => {
|
|
|
206
295
|
const legsWithDuplicatedProducts = [...fareProductItinerary.legs];
|
|
207
296
|
legsWithDuplicatedProducts[3].fareProducts =
|
|
208
297
|
legsWithDuplicatedProducts[1].fareProducts;
|
|
209
|
-
const result = getItineraryCost(
|
|
210
|
-
fareProductItinerary.legs,
|
|
211
|
-
"orca:cash",
|
|
212
|
-
"orca:regular"
|
|
213
|
-
);
|
|
298
|
+
const result = getItineraryCost(fareProductItinerary.legs, null, null);
|
|
214
299
|
expect(result.amount).toEqual(2.75);
|
|
215
300
|
expect(result.currency).toEqual({
|
|
216
301
|
code: "USD",
|