@opentripplanner/core-utils 13.0.0-alpha.4 → 13.0.1
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/__mocks__/fake-route-data.story.json +5425 -0
- package/esm/__mocks__/fake-transit-operators.story.json +97 -0
- package/esm/__tests__/__mocks__/routes.json +234 -105
- package/esm/itinerary.js +4 -2
- package/esm/itinerary.js.map +1 -1
- package/esm/otpSchema.json +0 -12
- package/esm/profile.js +1 -1
- package/esm/profile.js.map +1 -1
- package/esm/query-gen.js +2 -4
- package/esm/query-gen.js.map +1 -1
- package/esm/query.js +1 -4
- package/esm/query.js.map +1 -1
- package/esm/route.js +36 -21
- package/esm/route.js.map +1 -1
- package/esm/routes.json +234 -105
- package/esm/storage.js +2 -6
- package/esm/storage.js.map +1 -1
- package/esm/time.js +10 -0
- package/esm/time.js.map +1 -1
- package/lib/__mocks__/fake-route-data.story.json +5425 -0
- package/lib/__mocks__/fake-transit-operators.story.json +97 -0
- package/lib/__tests__/__mocks__/routes.json +234 -105
- package/lib/itinerary.d.ts.map +1 -1
- package/lib/itinerary.js +4 -2
- package/lib/itinerary.js.map +1 -1
- package/lib/otpSchema.json +0 -12
- package/lib/profile.js +1 -1
- package/lib/profile.js.map +1 -1
- package/lib/query-gen.js +2 -2
- package/lib/query-gen.js.map +1 -1
- package/lib/query.js +1 -4
- package/lib/query.js.map +1 -1
- package/lib/route.d.ts +35 -1
- package/lib/route.d.ts.map +1 -1
- package/lib/route.js +38 -17
- package/lib/route.js.map +1 -1
- package/lib/storage.d.ts.map +1 -1
- package/lib/storage.js +2 -6
- package/lib/storage.js.map +1 -1
- package/lib/time.d.ts +7 -0
- package/lib/time.d.ts.map +1 -1
- package/lib/time.js +10 -1
- package/lib/time.js.map +1 -1
- package/package.json +4 -4
- package/src/__mocks__/fake-route-data.story.json +5425 -0
- package/src/__mocks__/fake-transit-operators.story.json +97 -0
- package/src/__snapshots__/core-utils.story.tsx.snap +8382 -0
- package/src/__tests__/__mocks__/routes.json +234 -105
- package/src/__tests__/__snapshots__/route.js.snap +285 -95
- package/src/__tests__/route.js +27 -55
- package/src/core-utils.story.tsx +201 -2
- package/src/itinerary.ts +3 -2
- package/src/otpSchema.json +0 -12
- package/src/profile.js +1 -1
- package/src/query-gen.ts +2 -2
- package/src/query.js +1 -4
- package/src/route.ts +41 -21
- package/src/storage.ts +5 -9
- package/src/time.ts +9 -0
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -1,73 +1,85 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
|
-
exports[`util > route routeComparator should prioritize routes with
|
|
3
|
+
exports[`util > route routeComparator should prioritize OTP1 routes with valid sortOrder 1`] = `
|
|
4
4
|
Array [
|
|
5
5
|
Object {
|
|
6
|
-
"
|
|
6
|
+
"agencyId": "bcd",
|
|
7
|
+
"longName": "Around town",
|
|
7
8
|
"mode": "BUS",
|
|
8
|
-
"shortName": "
|
|
9
|
-
"sortOrder":
|
|
9
|
+
"shortName": "20",
|
|
10
|
+
"sortOrder": 2,
|
|
10
11
|
},
|
|
11
12
|
Object {
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
"shortName": "
|
|
13
|
+
"agencyId": "bcd",
|
|
14
|
+
"longName": "Around another town",
|
|
15
|
+
"shortName": "3",
|
|
15
16
|
"sortOrder": -999,
|
|
17
|
+
"type": 3,
|
|
16
18
|
},
|
|
17
19
|
]
|
|
18
20
|
`;
|
|
19
21
|
|
|
20
|
-
exports[`util > route routeComparator should prioritize routes with
|
|
22
|
+
exports[`util > route routeComparator should prioritize OTP2 routes with valid sortOrder 1`] = `
|
|
21
23
|
Array [
|
|
22
24
|
Object {
|
|
23
|
-
"longName": "
|
|
25
|
+
"longName": "Loop route",
|
|
24
26
|
"mode": "BUS",
|
|
25
|
-
"shortName": "
|
|
27
|
+
"shortName": "2",
|
|
26
28
|
"sortOrder": -999,
|
|
27
29
|
},
|
|
28
30
|
Object {
|
|
29
|
-
"longName": "
|
|
31
|
+
"longName": "Across town",
|
|
30
32
|
"mode": "BUS",
|
|
31
|
-
"
|
|
33
|
+
"shortName": "10",
|
|
34
|
+
"sortOrder": 10,
|
|
35
|
+
},
|
|
36
|
+
Object {
|
|
37
|
+
"longName": "Around another town",
|
|
38
|
+
"shortName": "3",
|
|
39
|
+
"sortOrder": null,
|
|
40
|
+
"type": 3,
|
|
32
41
|
},
|
|
33
42
|
]
|
|
34
43
|
`;
|
|
35
44
|
|
|
36
|
-
exports[`util > route routeComparator should prioritize routes with
|
|
45
|
+
exports[`util > route routeComparator should prioritize routes with alphabetic shortNames over integer shortNames 1`] = `
|
|
37
46
|
Array [
|
|
38
47
|
Object {
|
|
39
|
-
"
|
|
40
|
-
"
|
|
48
|
+
"agencyId": "bcd",
|
|
49
|
+
"longName": "A-line",
|
|
50
|
+
"mode": "BUS",
|
|
51
|
+
"shortName": "A",
|
|
41
52
|
"sortOrder": -999,
|
|
42
|
-
"type": 3,
|
|
43
53
|
},
|
|
44
54
|
Object {
|
|
45
|
-
"
|
|
55
|
+
"agencyId": "bcd",
|
|
56
|
+
"longName": "Loop route",
|
|
46
57
|
"mode": "BUS",
|
|
47
|
-
"shortName": "
|
|
48
|
-
"sortOrder":
|
|
58
|
+
"shortName": "2",
|
|
59
|
+
"sortOrder": -999,
|
|
49
60
|
},
|
|
50
61
|
]
|
|
51
62
|
`;
|
|
52
63
|
|
|
53
|
-
exports[`util > route routeComparator should
|
|
64
|
+
exports[`util > route routeComparator should prioritize routes with shortNames over those with just longNames 1`] = `
|
|
54
65
|
Array [
|
|
55
66
|
Object {
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
"
|
|
67
|
+
"agencyId": "bcd",
|
|
68
|
+
"longName": "B-line",
|
|
69
|
+
"mode": "BUS",
|
|
70
|
+
"shortName": "B",
|
|
71
|
+
"sortOrder": -999,
|
|
60
72
|
},
|
|
61
73
|
Object {
|
|
62
|
-
"
|
|
63
|
-
"
|
|
64
|
-
"
|
|
65
|
-
"sortOrder":
|
|
74
|
+
"agencyId": "bcd",
|
|
75
|
+
"longName": "A meandering route",
|
|
76
|
+
"mode": "BUS",
|
|
77
|
+
"sortOrder": -999,
|
|
66
78
|
},
|
|
67
79
|
]
|
|
68
80
|
`;
|
|
69
81
|
|
|
70
|
-
exports[`util > route routeComparator should sort routes
|
|
82
|
+
exports[`util > route routeComparator should sort OTP1 routes on all of the criteria at once 1`] = `
|
|
71
83
|
Array [
|
|
72
84
|
Object {
|
|
73
85
|
"agencyId": "abc",
|
|
@@ -76,6 +88,7 @@ Array [
|
|
|
76
88
|
"mode": "BUS",
|
|
77
89
|
"routeId": "2:erx",
|
|
78
90
|
"shortName": "30X",
|
|
91
|
+
"sortOrder": 10,
|
|
79
92
|
},
|
|
80
93
|
Object {
|
|
81
94
|
"agencyId": "abc",
|
|
@@ -84,110 +97,135 @@ Array [
|
|
|
84
97
|
"mode": "RAIL",
|
|
85
98
|
"routeId": "1:it2",
|
|
86
99
|
"shortName": "IC",
|
|
100
|
+
"sortOrder": 10,
|
|
87
101
|
},
|
|
88
|
-
]
|
|
89
|
-
`;
|
|
90
|
-
|
|
91
|
-
exports[`util > route routeComparator should sort routes based off of integer shortName 1`] = `
|
|
92
|
-
Array [
|
|
93
102
|
Object {
|
|
94
|
-
"
|
|
103
|
+
"agencyId": "bcd",
|
|
104
|
+
"longName": "Yellow line Subway",
|
|
105
|
+
"mode": "SUBWAY",
|
|
106
|
+
"shortName": "Yellow",
|
|
107
|
+
"sortOrder": 2,
|
|
108
|
+
},
|
|
109
|
+
Object {
|
|
110
|
+
"agencyId": "bcd",
|
|
111
|
+
"longName": "Intercity Train",
|
|
112
|
+
"mode": "RAIL",
|
|
113
|
+
"shortName": "IC",
|
|
114
|
+
"sortOrder": 2,
|
|
115
|
+
},
|
|
116
|
+
Object {
|
|
117
|
+
"agencyId": "bcd",
|
|
118
|
+
"longName": "Local route",
|
|
95
119
|
"mode": "BUS",
|
|
96
|
-
"shortName": "
|
|
97
|
-
"sortOrder":
|
|
120
|
+
"shortName": "6",
|
|
121
|
+
"sortOrder": 2,
|
|
98
122
|
},
|
|
99
123
|
Object {
|
|
100
|
-
"
|
|
101
|
-
"
|
|
102
|
-
"
|
|
103
|
-
"
|
|
124
|
+
"agencyId": "bcd",
|
|
125
|
+
"longName": "Around town",
|
|
126
|
+
"mode": "BUS",
|
|
127
|
+
"shortName": "20",
|
|
128
|
+
"sortOrder": 2,
|
|
104
129
|
},
|
|
105
|
-
]
|
|
106
|
-
`;
|
|
107
|
-
|
|
108
|
-
exports[`util > route routeComparator should sort routes based off of longNames 1`] = `
|
|
109
|
-
Array [
|
|
110
130
|
Object {
|
|
131
|
+
"agencyId": "bcd",
|
|
111
132
|
"longName": "Express route",
|
|
112
133
|
"mode": "BUS",
|
|
113
134
|
"shortName": "30",
|
|
114
135
|
"sortOrder": 2,
|
|
115
136
|
},
|
|
116
137
|
Object {
|
|
138
|
+
"agencyId": "bcd",
|
|
117
139
|
"longName": "Variation of express route",
|
|
118
140
|
"mode": "BUS",
|
|
119
141
|
"shortName": "30",
|
|
120
142
|
"sortOrder": 2,
|
|
121
143
|
},
|
|
122
|
-
]
|
|
123
|
-
`;
|
|
124
|
-
|
|
125
|
-
exports[`util > route routeComparator should sort routes based off of shortNames 1`] = `
|
|
126
|
-
Array [
|
|
127
144
|
Object {
|
|
145
|
+
"agencyId": "bcd",
|
|
146
|
+
"longName": "Zig-zagging route",
|
|
147
|
+
"mode": "BUS",
|
|
148
|
+
"shortName": "30",
|
|
149
|
+
"sortOrder": 2,
|
|
150
|
+
},
|
|
151
|
+
Object {
|
|
152
|
+
"agencyId": "bcd",
|
|
153
|
+
"longName": "Xpress route C",
|
|
154
|
+
"mode": "BUS",
|
|
155
|
+
"shortName": "30C",
|
|
156
|
+
"sortOrder": 2,
|
|
157
|
+
},
|
|
158
|
+
Object {
|
|
159
|
+
"agencyId": "bcd",
|
|
160
|
+
"longName": "Across town",
|
|
161
|
+
"mode": "BUS",
|
|
162
|
+
"shortName": "10",
|
|
163
|
+
"sortOrder": 10,
|
|
164
|
+
},
|
|
165
|
+
Object {
|
|
166
|
+
"agencyId": "bcd",
|
|
128
167
|
"longName": "A-line",
|
|
129
168
|
"mode": "BUS",
|
|
130
169
|
"shortName": "A",
|
|
131
170
|
"sortOrder": -999,
|
|
132
171
|
},
|
|
133
172
|
Object {
|
|
173
|
+
"agencyId": "bcd",
|
|
134
174
|
"longName": "B-line",
|
|
135
175
|
"mode": "BUS",
|
|
136
176
|
"shortName": "B",
|
|
137
177
|
"sortOrder": -999,
|
|
138
178
|
},
|
|
139
|
-
]
|
|
140
|
-
`;
|
|
141
|
-
|
|
142
|
-
exports[`util > route routeComparator should sort routes based off of sortOrder 1`] = `
|
|
143
|
-
Array [
|
|
144
|
-
Object {
|
|
145
|
-
"longName": "Around town",
|
|
146
|
-
"mode": "BUS",
|
|
147
|
-
"shortName": "20",
|
|
148
|
-
"sortOrder": 2,
|
|
149
|
-
},
|
|
150
179
|
Object {
|
|
151
|
-
"
|
|
180
|
+
"agencyId": "bcd",
|
|
181
|
+
"longName": "Loop route",
|
|
152
182
|
"mode": "BUS",
|
|
153
|
-
"shortName": "
|
|
154
|
-
"sortOrder":
|
|
183
|
+
"shortName": "2",
|
|
184
|
+
"sortOrder": -999,
|
|
155
185
|
},
|
|
156
|
-
]
|
|
157
|
-
`;
|
|
158
|
-
|
|
159
|
-
exports[`util > route routeComparator should sort routes based off of transitOperators sort value when a match is found 1`] = `
|
|
160
|
-
Array [
|
|
161
186
|
Object {
|
|
162
|
-
"agencyId": "
|
|
163
|
-
"
|
|
164
|
-
"
|
|
165
|
-
"
|
|
166
|
-
"
|
|
167
|
-
"shortName": "IC",
|
|
187
|
+
"agencyId": "bcd",
|
|
188
|
+
"longName": "Around another town",
|
|
189
|
+
"shortName": "3",
|
|
190
|
+
"sortOrder": -999,
|
|
191
|
+
"type": 3,
|
|
168
192
|
},
|
|
169
193
|
Object {
|
|
170
|
-
"agencyId": "
|
|
171
|
-
"agencyName": "Acclaimed agency 1",
|
|
194
|
+
"agencyId": "bcd",
|
|
172
195
|
"longName": "Express route X",
|
|
173
196
|
"mode": "BUS",
|
|
174
|
-
"routeId": "2:erx",
|
|
175
197
|
"shortName": "30X",
|
|
176
198
|
},
|
|
199
|
+
Object {
|
|
200
|
+
"agencyId": "bcd",
|
|
201
|
+
"longName": "A meandering route",
|
|
202
|
+
"mode": "BUS",
|
|
203
|
+
"sortOrder": -999,
|
|
204
|
+
},
|
|
177
205
|
]
|
|
178
206
|
`;
|
|
179
207
|
|
|
180
|
-
exports[`util > route routeComparator should sort routes on all of the criteria at once 1`] = `
|
|
208
|
+
exports[`util > route routeComparator should sort OTP2 routes on all of the criteria at once 1`] = `
|
|
181
209
|
Array [
|
|
182
210
|
Object {
|
|
183
|
-
"
|
|
184
|
-
|
|
185
|
-
|
|
211
|
+
"agency": Object {
|
|
212
|
+
"id": "abc",
|
|
213
|
+
"name": "Acclaimed agency 1",
|
|
214
|
+
},
|
|
215
|
+
"longName": "Express route X",
|
|
216
|
+
"mode": "BUS",
|
|
217
|
+
"routeId": "2:erx",
|
|
218
|
+
"shortName": "30X",
|
|
186
219
|
"sortOrder": 2,
|
|
187
220
|
},
|
|
188
221
|
Object {
|
|
189
|
-
"
|
|
222
|
+
"agency": Object {
|
|
223
|
+
"id": "abc",
|
|
224
|
+
"name": "Agency 1",
|
|
225
|
+
},
|
|
226
|
+
"longName": "Intercity Train 2",
|
|
190
227
|
"mode": "RAIL",
|
|
228
|
+
"routeId": "1:it2",
|
|
191
229
|
"shortName": "IC",
|
|
192
230
|
"sortOrder": 2,
|
|
193
231
|
},
|
|
@@ -197,12 +235,6 @@ Array [
|
|
|
197
235
|
"shortName": "A",
|
|
198
236
|
"sortOrder": -999,
|
|
199
237
|
},
|
|
200
|
-
Object {
|
|
201
|
-
"longName": "B-line",
|
|
202
|
-
"mode": "BUS",
|
|
203
|
-
"shortName": "B",
|
|
204
|
-
"sortOrder": -999,
|
|
205
|
-
},
|
|
206
238
|
Object {
|
|
207
239
|
"longName": "Loop route",
|
|
208
240
|
"mode": "BUS",
|
|
@@ -210,10 +242,16 @@ Array [
|
|
|
210
242
|
"sortOrder": -999,
|
|
211
243
|
},
|
|
212
244
|
Object {
|
|
213
|
-
"longName": "
|
|
214
|
-
"
|
|
215
|
-
"
|
|
216
|
-
"
|
|
245
|
+
"longName": "Yellow line Subway",
|
|
246
|
+
"mode": "SUBWAY",
|
|
247
|
+
"shortName": "Yellow",
|
|
248
|
+
"sortOrder": 2,
|
|
249
|
+
},
|
|
250
|
+
Object {
|
|
251
|
+
"longName": "Intercity Train",
|
|
252
|
+
"mode": "RAIL",
|
|
253
|
+
"shortName": "IC",
|
|
254
|
+
"sortOrder": 2,
|
|
217
255
|
},
|
|
218
256
|
Object {
|
|
219
257
|
"longName": "Local route",
|
|
@@ -263,27 +301,179 @@ Array [
|
|
|
263
301
|
"shortName": "10",
|
|
264
302
|
"sortOrder": 10,
|
|
265
303
|
},
|
|
304
|
+
Object {
|
|
305
|
+
"longName": "B-line",
|
|
306
|
+
"mode": "BUS",
|
|
307
|
+
"shortName": "B",
|
|
308
|
+
},
|
|
309
|
+
Object {
|
|
310
|
+
"longName": "Around another town",
|
|
311
|
+
"shortName": "3",
|
|
312
|
+
"sortOrder": null,
|
|
313
|
+
"type": 3,
|
|
314
|
+
},
|
|
266
315
|
Object {
|
|
267
316
|
"longName": "A meandering route",
|
|
268
317
|
"mode": "BUS",
|
|
318
|
+
},
|
|
319
|
+
]
|
|
320
|
+
`;
|
|
321
|
+
|
|
322
|
+
exports[`util > route routeComparator should sort based off of route type 1`] = `
|
|
323
|
+
Array [
|
|
324
|
+
Object {
|
|
325
|
+
"agencyId": "bcd",
|
|
326
|
+
"longName": "Yellow line Subway",
|
|
327
|
+
"mode": "SUBWAY",
|
|
328
|
+
"shortName": "Yellow",
|
|
329
|
+
"sortOrder": 2,
|
|
330
|
+
},
|
|
331
|
+
Object {
|
|
332
|
+
"agencyId": "bcd",
|
|
333
|
+
"longName": "Intercity Train",
|
|
334
|
+
"mode": "RAIL",
|
|
335
|
+
"shortName": "IC",
|
|
336
|
+
"sortOrder": 2,
|
|
337
|
+
},
|
|
338
|
+
]
|
|
339
|
+
`;
|
|
340
|
+
|
|
341
|
+
exports[`util > route routeComparator should sort routes based off of agencyName if no transitOperators are defined 1`] = `
|
|
342
|
+
Array [
|
|
343
|
+
Object {
|
|
344
|
+
"agencyId": "abc",
|
|
345
|
+
"agencyName": "Acclaimed agency 1",
|
|
346
|
+
"longName": "Express route X",
|
|
347
|
+
"mode": "BUS",
|
|
348
|
+
"routeId": "2:erx",
|
|
349
|
+
"shortName": "30X",
|
|
350
|
+
"sortOrder": 10,
|
|
351
|
+
},
|
|
352
|
+
Object {
|
|
353
|
+
"agencyId": "abc",
|
|
354
|
+
"agencyName": "Agency 1",
|
|
355
|
+
"longName": "Intercity Train 2",
|
|
356
|
+
"mode": "RAIL",
|
|
357
|
+
"routeId": "1:it2",
|
|
358
|
+
"shortName": "IC",
|
|
359
|
+
"sortOrder": 10,
|
|
360
|
+
},
|
|
361
|
+
]
|
|
362
|
+
`;
|
|
363
|
+
|
|
364
|
+
exports[`util > route routeComparator should sort routes based off of integer shortName 1`] = `
|
|
365
|
+
Array [
|
|
366
|
+
Object {
|
|
367
|
+
"agencyId": "bcd",
|
|
368
|
+
"longName": "Loop route",
|
|
369
|
+
"mode": "BUS",
|
|
370
|
+
"shortName": "2",
|
|
269
371
|
"sortOrder": -999,
|
|
270
372
|
},
|
|
373
|
+
Object {
|
|
374
|
+
"agencyId": "bcd",
|
|
375
|
+
"longName": "Around another town",
|
|
376
|
+
"shortName": "3",
|
|
377
|
+
"sortOrder": -999,
|
|
378
|
+
"type": 3,
|
|
379
|
+
},
|
|
380
|
+
]
|
|
381
|
+
`;
|
|
382
|
+
|
|
383
|
+
exports[`util > route routeComparator should sort routes based off of longNames 1`] = `
|
|
384
|
+
Array [
|
|
385
|
+
Object {
|
|
386
|
+
"agencyId": "bcd",
|
|
387
|
+
"longName": "Express route",
|
|
388
|
+
"mode": "BUS",
|
|
389
|
+
"shortName": "30",
|
|
390
|
+
"sortOrder": 2,
|
|
391
|
+
},
|
|
392
|
+
Object {
|
|
393
|
+
"agencyId": "bcd",
|
|
394
|
+
"longName": "Variation of express route",
|
|
395
|
+
"mode": "BUS",
|
|
396
|
+
"shortName": "30",
|
|
397
|
+
"sortOrder": 2,
|
|
398
|
+
},
|
|
399
|
+
]
|
|
400
|
+
`;
|
|
401
|
+
|
|
402
|
+
exports[`util > route routeComparator should sort routes based off of shortNames 1`] = `
|
|
403
|
+
Array [
|
|
404
|
+
Object {
|
|
405
|
+
"agencyId": "bcd",
|
|
406
|
+
"longName": "A-line",
|
|
407
|
+
"mode": "BUS",
|
|
408
|
+
"shortName": "A",
|
|
409
|
+
"sortOrder": -999,
|
|
410
|
+
},
|
|
411
|
+
Object {
|
|
412
|
+
"agencyId": "bcd",
|
|
413
|
+
"longName": "B-line",
|
|
414
|
+
"mode": "BUS",
|
|
415
|
+
"shortName": "B",
|
|
416
|
+
"sortOrder": -999,
|
|
417
|
+
},
|
|
418
|
+
]
|
|
419
|
+
`;
|
|
420
|
+
|
|
421
|
+
exports[`util > route routeComparator should sort routes based off of sortOrder 1`] = `
|
|
422
|
+
Array [
|
|
423
|
+
Object {
|
|
424
|
+
"agencyId": "bcd",
|
|
425
|
+
"longName": "Around town",
|
|
426
|
+
"mode": "BUS",
|
|
427
|
+
"shortName": "20",
|
|
428
|
+
"sortOrder": 2,
|
|
429
|
+
},
|
|
430
|
+
Object {
|
|
431
|
+
"agencyId": "bcd",
|
|
432
|
+
"longName": "Across town",
|
|
433
|
+
"mode": "BUS",
|
|
434
|
+
"shortName": "10",
|
|
435
|
+
"sortOrder": 10,
|
|
436
|
+
},
|
|
437
|
+
]
|
|
438
|
+
`;
|
|
439
|
+
|
|
440
|
+
exports[`util > route routeComparator should sort routes based off of transitOperators sort value when a match is found 1`] = `
|
|
441
|
+
Array [
|
|
442
|
+
Object {
|
|
443
|
+
"agencyId": "abc",
|
|
444
|
+
"agencyName": "Agency 1",
|
|
445
|
+
"longName": "Intercity Train 2",
|
|
446
|
+
"mode": "RAIL",
|
|
447
|
+
"routeId": "1:it2",
|
|
448
|
+
"shortName": "IC",
|
|
449
|
+
"sortOrder": 10,
|
|
450
|
+
},
|
|
451
|
+
Object {
|
|
452
|
+
"agencyId": "abc",
|
|
453
|
+
"agencyName": "Acclaimed agency 1",
|
|
454
|
+
"longName": "Express route X",
|
|
455
|
+
"mode": "BUS",
|
|
456
|
+
"routeId": "2:erx",
|
|
457
|
+
"shortName": "30X",
|
|
458
|
+
"sortOrder": 10,
|
|
459
|
+
},
|
|
271
460
|
]
|
|
272
461
|
`;
|
|
273
462
|
|
|
274
463
|
exports[`util > route routeComparator should sort routes with alphanumeric shortNames 1`] = `
|
|
275
464
|
Array [
|
|
276
465
|
Object {
|
|
466
|
+
"agencyId": "bcd",
|
|
277
467
|
"longName": "Xpress route C",
|
|
278
468
|
"mode": "BUS",
|
|
279
469
|
"shortName": "30C",
|
|
280
470
|
"sortOrder": 2,
|
|
281
471
|
},
|
|
282
472
|
Object {
|
|
473
|
+
"agencyId": "bcd",
|
|
283
474
|
"longName": "Express route X",
|
|
284
475
|
"mode": "BUS",
|
|
285
476
|
"shortName": "30X",
|
|
286
|
-
"sortOrder": 2,
|
|
287
477
|
},
|
|
288
478
|
]
|
|
289
479
|
`;
|
package/src/__tests__/route.js
CHANGED
|
@@ -5,25 +5,7 @@ import {
|
|
|
5
5
|
makeRouteComparator
|
|
6
6
|
} from "../route";
|
|
7
7
|
|
|
8
|
-
const {
|
|
9
|
-
route1,
|
|
10
|
-
route2,
|
|
11
|
-
route3,
|
|
12
|
-
route4,
|
|
13
|
-
route5,
|
|
14
|
-
route6,
|
|
15
|
-
route7,
|
|
16
|
-
route8,
|
|
17
|
-
route9,
|
|
18
|
-
route10,
|
|
19
|
-
route11,
|
|
20
|
-
route12,
|
|
21
|
-
route13,
|
|
22
|
-
route14,
|
|
23
|
-
route15,
|
|
24
|
-
route16,
|
|
25
|
-
route17
|
|
26
|
-
} = require("./__mocks__/routes.json");
|
|
8
|
+
const { otp1Routes, otp2Routes } = require("./__mocks__/routes.json");
|
|
27
9
|
|
|
28
10
|
function sortRoutes(...routes) {
|
|
29
11
|
routes.sort(makeRouteComparator());
|
|
@@ -47,7 +29,7 @@ describe("util > route", () => {
|
|
|
47
29
|
});
|
|
48
30
|
});
|
|
49
31
|
|
|
50
|
-
describe("
|
|
32
|
+
describe("getTransitOperatorFromOtp1Route", () => {
|
|
51
33
|
const otpRoute = { agencyId: "abc", id: "1:abc" };
|
|
52
34
|
it("should get a transit operator", () => {
|
|
53
35
|
const expectedTransitOperator = { agencyId: "abc", feedId: "1" };
|
|
@@ -65,8 +47,8 @@ describe("util > route", () => {
|
|
|
65
47
|
});
|
|
66
48
|
|
|
67
49
|
describe("routeComparator", () => {
|
|
68
|
-
it("should sort routes based off of agencyName", () => {
|
|
69
|
-
expect(sortRoutes(
|
|
50
|
+
it("should sort routes based off of agencyName if no transitOperators are defined", () => {
|
|
51
|
+
expect(sortRoutes(otp1Routes[15], otp1Routes[16])).toMatchSnapshot();
|
|
70
52
|
});
|
|
71
53
|
|
|
72
54
|
it("should sort routes based off of transitOperators sort value when a match is found", () => {
|
|
@@ -74,66 +56,56 @@ describe("util > route", () => {
|
|
|
74
56
|
{ agencyId: "abc", feedId: "1", order: 2 },
|
|
75
57
|
{ agencyId: "abc", feedId: "2", order: 1 }
|
|
76
58
|
]);
|
|
77
|
-
const routes = [
|
|
59
|
+
const routes = [otp1Routes[15], otp1Routes[16]];
|
|
78
60
|
expect(routes.sort(comparatorWithTransitOperators)).toMatchSnapshot();
|
|
79
61
|
});
|
|
80
62
|
|
|
81
63
|
it("should sort routes based off of sortOrder", () => {
|
|
82
|
-
expect(sortRoutes(
|
|
64
|
+
expect(sortRoutes(otp1Routes[0], otp1Routes[1])).toMatchSnapshot();
|
|
83
65
|
});
|
|
84
66
|
|
|
85
|
-
it("should prioritize routes with valid sortOrder", () => {
|
|
86
|
-
expect(sortRoutes(
|
|
67
|
+
it("should prioritize OTP1 routes with valid sortOrder", () => {
|
|
68
|
+
expect(sortRoutes(otp1Routes[1], otp1Routes[2])).toMatchSnapshot();
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it("should prioritize OTP2 routes with valid sortOrder", () => {
|
|
72
|
+
expect(
|
|
73
|
+
sortRoutes(otp2Routes[0], otp2Routes[2], otp2Routes[3])
|
|
74
|
+
).toMatchSnapshot();
|
|
87
75
|
});
|
|
88
76
|
|
|
89
77
|
it("should sort routes based off of integer shortName", () => {
|
|
90
|
-
expect(sortRoutes(
|
|
78
|
+
expect(sortRoutes(otp1Routes[2], otp1Routes[3])).toMatchSnapshot();
|
|
91
79
|
});
|
|
92
80
|
|
|
93
|
-
it("should prioritize routes with
|
|
94
|
-
expect(sortRoutes(
|
|
81
|
+
it("should prioritize routes with alphabetic shortNames over integer shortNames", () => {
|
|
82
|
+
expect(sortRoutes(otp1Routes[3], otp1Routes[4])).toMatchSnapshot();
|
|
95
83
|
});
|
|
96
84
|
|
|
97
85
|
it("should sort routes based off of shortNames", () => {
|
|
98
|
-
expect(sortRoutes(
|
|
86
|
+
expect(sortRoutes(otp1Routes[4], otp1Routes[5])).toMatchSnapshot();
|
|
99
87
|
});
|
|
100
88
|
|
|
101
89
|
it("should sort routes with alphanumeric shortNames", () => {
|
|
102
|
-
expect(sortRoutes(
|
|
90
|
+
expect(sortRoutes(otp1Routes[13], otp1Routes[14])).toMatchSnapshot();
|
|
103
91
|
});
|
|
104
92
|
|
|
105
93
|
it("should prioritize routes with shortNames over those with just longNames", () => {
|
|
106
|
-
expect(sortRoutes(
|
|
94
|
+
expect(sortRoutes(otp1Routes[5], otp1Routes[6])).toMatchSnapshot();
|
|
107
95
|
});
|
|
108
96
|
|
|
109
97
|
it("should sort routes based off of longNames", () => {
|
|
110
|
-
expect(sortRoutes(
|
|
98
|
+
expect(sortRoutes(otp1Routes[8], otp1Routes[9])).toMatchSnapshot();
|
|
111
99
|
});
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
route2,
|
|
118
|
-
route3,
|
|
119
|
-
route4,
|
|
120
|
-
route5,
|
|
121
|
-
route6,
|
|
122
|
-
route7,
|
|
123
|
-
route8,
|
|
124
|
-
route9,
|
|
125
|
-
route10,
|
|
126
|
-
route11,
|
|
127
|
-
route12,
|
|
128
|
-
route13,
|
|
129
|
-
route14,
|
|
130
|
-
route15
|
|
131
|
-
)
|
|
132
|
-
).toMatchSnapshot();
|
|
100
|
+
it("should sort OTP1 routes on all of the criteria at once", () => {
|
|
101
|
+
expect(sortRoutes(...otp1Routes)).toMatchSnapshot();
|
|
102
|
+
});
|
|
103
|
+
it("should sort OTP2 routes on all of the criteria at once", () => {
|
|
104
|
+
expect(sortRoutes(...otp2Routes)).toMatchSnapshot();
|
|
133
105
|
});
|
|
134
106
|
|
|
135
107
|
it("should sort based off of route type", () => {
|
|
136
|
-
expect(sortRoutes(
|
|
108
|
+
expect(sortRoutes(otp1Routes[11], otp1Routes[12])).toMatchSnapshot();
|
|
137
109
|
});
|
|
138
110
|
});
|
|
139
111
|
|