@mapbox/mcp-server 0.2.0 → 0.2.1-dev.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/dist/tools/MapboxApiBasedTool.d.ts +0 -7
- package/dist/tools/MapboxApiBasedTool.d.ts.map +1 -1
- package/dist/tools/MapboxApiBasedTool.js +2 -24
- package/dist/tools/MapboxApiBasedTool.js.map +1 -1
- package/dist/tools/category-search-tool/CategorySearchTool.d.ts +6 -55
- package/dist/tools/category-search-tool/CategorySearchTool.d.ts.map +1 -1
- package/dist/tools/category-search-tool/CategorySearchTool.js +19 -47
- package/dist/tools/category-search-tool/CategorySearchTool.js.map +1 -1
- package/dist/tools/category-search-tool/CategorySearchTool.test.js +10 -90
- package/dist/tools/category-search-tool/CategorySearchTool.test.js.map +1 -1
- package/dist/tools/directions-tool/DirectionsTool.d.ts +3 -18
- package/dist/tools/directions-tool/DirectionsTool.d.ts.map +1 -1
- package/dist/tools/directions-tool/DirectionsTool.js +6 -6
- package/dist/tools/directions-tool/DirectionsTool.js.map +1 -1
- package/dist/tools/directions-tool/DirectionsTool.test.js +118 -122
- package/dist/tools/directions-tool/DirectionsTool.test.js.map +1 -1
- package/dist/tools/forward-geocode-tool/ForwardGeocodeTool.d.ts +9 -55
- package/dist/tools/forward-geocode-tool/ForwardGeocodeTool.d.ts.map +1 -1
- package/dist/tools/forward-geocode-tool/ForwardGeocodeTool.js +21 -44
- package/dist/tools/forward-geocode-tool/ForwardGeocodeTool.js.map +1 -1
- package/dist/tools/forward-geocode-tool/ForwardGeocodeTool.test.js +10 -90
- package/dist/tools/forward-geocode-tool/ForwardGeocodeTool.test.js.map +1 -1
- package/dist/tools/isochrone-tool/IsochroneTool.d.ts +3 -18
- package/dist/tools/isochrone-tool/IsochroneTool.d.ts.map +1 -1
- package/dist/tools/isochrone-tool/IsochroneTool.js +3 -6
- package/dist/tools/isochrone-tool/IsochroneTool.js.map +1 -1
- package/dist/tools/isochrone-tool/IsochroneTool.test.js +7 -8
- package/dist/tools/isochrone-tool/IsochroneTool.test.js.map +1 -1
- package/dist/tools/matrix-tool/MatrixTool.d.ts +3 -18
- package/dist/tools/matrix-tool/MatrixTool.d.ts.map +1 -1
- package/dist/tools/matrix-tool/MatrixTool.js +6 -6
- package/dist/tools/matrix-tool/MatrixTool.js.map +1 -1
- package/dist/tools/matrix-tool/MatrixTool.test.js +115 -128
- package/dist/tools/matrix-tool/MatrixTool.test.js.map +1 -1
- package/dist/tools/poi-search-tool/PoiSearchTool.d.ts +9 -73
- package/dist/tools/poi-search-tool/PoiSearchTool.d.ts.map +1 -1
- package/dist/tools/poi-search-tool/PoiSearchTool.js +22 -53
- package/dist/tools/poi-search-tool/PoiSearchTool.js.map +1 -1
- package/dist/tools/poi-search-tool/PoiSearchTool.test.js +10 -90
- package/dist/tools/poi-search-tool/PoiSearchTool.test.js.map +1 -1
- package/dist/tools/reverse-geocode-tool/ReverseGeocodeTool.d.ts +2 -5
- package/dist/tools/reverse-geocode-tool/ReverseGeocodeTool.d.ts.map +1 -1
- package/dist/tools/reverse-geocode-tool/ReverseGeocodeTool.js +3 -13
- package/dist/tools/reverse-geocode-tool/ReverseGeocodeTool.js.map +1 -1
- package/dist/tools/reverse-geocode-tool/ReverseGeocodeTool.test.js +7 -70
- package/dist/tools/reverse-geocode-tool/ReverseGeocodeTool.test.js.map +1 -1
- package/dist/tools/static-map-image-tool/StaticMapImageTool.d.ts +6 -36
- package/dist/tools/static-map-image-tool/StaticMapImageTool.d.ts.map +1 -1
- package/dist/tools/static-map-image-tool/StaticMapImageTool.js +9 -12
- package/dist/tools/static-map-image-tool/StaticMapImageTool.js.map +1 -1
- package/dist/tools/static-map-image-tool/StaticMapImageTool.test.js +47 -48
- package/dist/tools/static-map-image-tool/StaticMapImageTool.test.js.map +1 -1
- package/dist/version.json +4 -4
- package/package.json +1 -1
- package/dist/tools/MapboxApiBasedTool.test.d.ts +0 -2
- package/dist/tools/MapboxApiBasedTool.test.d.ts.map +0 -1
- package/dist/tools/MapboxApiBasedTool.test.js +0 -143
- package/dist/tools/MapboxApiBasedTool.test.js.map +0 -1
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
process.env.MAPBOX_ACCESS_TOKEN =
|
|
2
|
-
'eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJ0ZXN0In0.signature';
|
|
1
|
+
process.env.MAPBOX_ACCESS_TOKEN = 'test-token';
|
|
3
2
|
import { cleanup } from '../../utils/requestUtils.js';
|
|
4
3
|
import { setupFetch, assertHeadersSent } from '../../utils/requestUtils.test-helpers.js';
|
|
5
4
|
import { DirectionsTool } from './DirectionsTool.js';
|
|
@@ -12,8 +11,8 @@ describe('DirectionsTool', () => {
|
|
|
12
11
|
const mockFetch = setupFetch();
|
|
13
12
|
await new DirectionsTool().run({
|
|
14
13
|
coordinates: [
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
[-74.102094, 40.692815],
|
|
15
|
+
[-74.1022094, 40.792815]
|
|
17
16
|
]
|
|
18
17
|
});
|
|
19
18
|
assertHeadersSent(mockFetch);
|
|
@@ -22,8 +21,8 @@ describe('DirectionsTool', () => {
|
|
|
22
21
|
const mockFetch = setupFetch();
|
|
23
22
|
await new DirectionsTool().run({
|
|
24
23
|
coordinates: [
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
[-73.989, 40.733],
|
|
25
|
+
[-73.979, 40.743]
|
|
27
26
|
]
|
|
28
27
|
});
|
|
29
28
|
const calledUrl = mockFetch.mock.calls[0][0];
|
|
@@ -36,9 +35,9 @@ describe('DirectionsTool', () => {
|
|
|
36
35
|
const mockFetch = setupFetch();
|
|
37
36
|
await new DirectionsTool().run({
|
|
38
37
|
coordinates: [
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
38
|
+
[-122.42, 37.78],
|
|
39
|
+
[-122.4, 37.79],
|
|
40
|
+
[-122.39, 37.77]
|
|
42
41
|
],
|
|
43
42
|
routing_profile: 'walking',
|
|
44
43
|
geometries: 'geojson',
|
|
@@ -60,8 +59,8 @@ describe('DirectionsTool', () => {
|
|
|
60
59
|
const mockFetch = setupFetch();
|
|
61
60
|
await new DirectionsTool().run({
|
|
62
61
|
coordinates: [
|
|
63
|
-
|
|
64
|
-
|
|
62
|
+
[-118.24, 34.05],
|
|
63
|
+
[-118.3, 34.02]
|
|
65
64
|
]
|
|
66
65
|
});
|
|
67
66
|
const calledUrl = mockFetch.mock.calls[0][0];
|
|
@@ -76,8 +75,8 @@ describe('DirectionsTool', () => {
|
|
|
76
75
|
const mockFetch = setupFetch();
|
|
77
76
|
await new DirectionsTool().run({
|
|
78
77
|
coordinates: [
|
|
79
|
-
|
|
80
|
-
|
|
78
|
+
[-74.0, 40.7],
|
|
79
|
+
[-73.9, 40.8]
|
|
81
80
|
],
|
|
82
81
|
exclude: 'toll,point(-73.95 40.75)'
|
|
83
82
|
});
|
|
@@ -97,8 +96,8 @@ describe('DirectionsTool', () => {
|
|
|
97
96
|
});
|
|
98
97
|
const result = await new DirectionsTool().run({
|
|
99
98
|
coordinates: [
|
|
100
|
-
|
|
101
|
-
|
|
99
|
+
[-73.989, 40.733],
|
|
100
|
+
[-73.979, 40.743]
|
|
102
101
|
]
|
|
103
102
|
});
|
|
104
103
|
expect(result.is_error).toBe(true);
|
|
@@ -112,7 +111,7 @@ describe('DirectionsTool', () => {
|
|
|
112
111
|
const tool = new DirectionsTool();
|
|
113
112
|
// Test with only one coordinate (invalid)
|
|
114
113
|
await expect(tool.run({
|
|
115
|
-
coordinates: [
|
|
114
|
+
coordinates: [[-73.989, 40.733]]
|
|
116
115
|
})).resolves.toMatchObject({
|
|
117
116
|
is_error: true
|
|
118
117
|
});
|
|
@@ -126,10 +125,7 @@ describe('DirectionsTool', () => {
|
|
|
126
125
|
it('validates coordinates constraints - maximum allowed', async () => {
|
|
127
126
|
const tool = new DirectionsTool();
|
|
128
127
|
// Create an array of 26 coordinates (one more than allowed)
|
|
129
|
-
const tooManyCoords = Array(26).fill(
|
|
130
|
-
longitude: -73.989,
|
|
131
|
-
latitude: 40.733
|
|
132
|
-
});
|
|
128
|
+
const tooManyCoords = Array(26).fill([-73.989, 40.733]);
|
|
133
129
|
await expect(tool.run({
|
|
134
130
|
coordinates: tooManyCoords
|
|
135
131
|
})).resolves.toMatchObject({
|
|
@@ -140,8 +136,8 @@ describe('DirectionsTool', () => {
|
|
|
140
136
|
const mockFetch = setupFetch();
|
|
141
137
|
await new DirectionsTool().run({
|
|
142
138
|
coordinates: [
|
|
143
|
-
|
|
144
|
-
|
|
139
|
+
[-73.989, 40.733],
|
|
140
|
+
[-73.979, 40.743]
|
|
145
141
|
]
|
|
146
142
|
});
|
|
147
143
|
const calledUrl = mockFetch.mock.calls[0][0];
|
|
@@ -153,14 +149,14 @@ describe('DirectionsTool', () => {
|
|
|
153
149
|
// Create an array of exactly 25 coordinates (maximum allowed)
|
|
154
150
|
const maxCoords = Array(25)
|
|
155
151
|
.fill(0)
|
|
156
|
-
.map((_, i) =>
|
|
152
|
+
.map((_, i) => [-74 + i * 0.01, 40 + i * 0.01]);
|
|
157
153
|
await new DirectionsTool().run({
|
|
158
154
|
coordinates: maxCoords
|
|
159
155
|
});
|
|
160
156
|
const calledUrl = mockFetch.mock.calls[0][0];
|
|
161
157
|
// Check that all coordinates are properly encoded
|
|
162
158
|
for (let i = 0; i < maxCoords.length; i++) {
|
|
163
|
-
const
|
|
159
|
+
const [lng, lat] = maxCoords[i];
|
|
164
160
|
const semicolon = i < 24 ? '%3B' : '';
|
|
165
161
|
const expectedCoord = `${lng}%2C${lat}` + semicolon;
|
|
166
162
|
expect(calledUrl).toContain(expectedCoord);
|
|
@@ -172,8 +168,8 @@ describe('DirectionsTool', () => {
|
|
|
172
168
|
const mockFetch = setupFetch();
|
|
173
169
|
await new DirectionsTool().run({
|
|
174
170
|
coordinates: [
|
|
175
|
-
|
|
176
|
-
|
|
171
|
+
[-73.989, 40.733],
|
|
172
|
+
[-73.979, 40.743]
|
|
177
173
|
],
|
|
178
174
|
routing_profile: 'walking',
|
|
179
175
|
walking_speed: 2.5
|
|
@@ -186,8 +182,8 @@ describe('DirectionsTool', () => {
|
|
|
186
182
|
const mockFetch = setupFetch();
|
|
187
183
|
await new DirectionsTool().run({
|
|
188
184
|
coordinates: [
|
|
189
|
-
|
|
190
|
-
|
|
185
|
+
[-73.989, 40.733],
|
|
186
|
+
[-73.979, 40.743]
|
|
191
187
|
],
|
|
192
188
|
routing_profile: 'walking',
|
|
193
189
|
walkway_bias: 0.8
|
|
@@ -201,8 +197,8 @@ describe('DirectionsTool', () => {
|
|
|
201
197
|
// Test with driving profile
|
|
202
198
|
await expect(tool.run({
|
|
203
199
|
coordinates: [
|
|
204
|
-
|
|
205
|
-
|
|
200
|
+
[-73.989, 40.733],
|
|
201
|
+
[-73.979, 40.743]
|
|
206
202
|
],
|
|
207
203
|
routing_profile: 'driving',
|
|
208
204
|
walking_speed: 2.0
|
|
@@ -212,8 +208,8 @@ describe('DirectionsTool', () => {
|
|
|
212
208
|
// Test with cycling profile
|
|
213
209
|
await expect(tool.run({
|
|
214
210
|
coordinates: [
|
|
215
|
-
|
|
216
|
-
|
|
211
|
+
[-73.989, 40.733],
|
|
212
|
+
[-73.979, 40.743]
|
|
217
213
|
],
|
|
218
214
|
routing_profile: 'cycling',
|
|
219
215
|
walking_speed: 2.0
|
|
@@ -226,8 +222,8 @@ describe('DirectionsTool', () => {
|
|
|
226
222
|
// Test with driving-traffic profile
|
|
227
223
|
await expect(tool.run({
|
|
228
224
|
coordinates: [
|
|
229
|
-
|
|
230
|
-
|
|
225
|
+
[-73.989, 40.733],
|
|
226
|
+
[-73.979, 40.743]
|
|
231
227
|
],
|
|
232
228
|
routing_profile: 'driving-traffic',
|
|
233
229
|
walkway_bias: 0.5
|
|
@@ -237,8 +233,8 @@ describe('DirectionsTool', () => {
|
|
|
237
233
|
// Test with cycling profile
|
|
238
234
|
await expect(tool.run({
|
|
239
235
|
coordinates: [
|
|
240
|
-
|
|
241
|
-
|
|
236
|
+
[-73.989, 40.733],
|
|
237
|
+
[-73.979, 40.743]
|
|
242
238
|
],
|
|
243
239
|
routing_profile: 'cycling',
|
|
244
240
|
walkway_bias: -0.8
|
|
@@ -251,8 +247,8 @@ describe('DirectionsTool', () => {
|
|
|
251
247
|
// Test with value below minimum (0.14 m/s)
|
|
252
248
|
await expect(tool.run({
|
|
253
249
|
coordinates: [
|
|
254
|
-
|
|
255
|
-
|
|
250
|
+
[-73.989, 40.733],
|
|
251
|
+
[-73.979, 40.743]
|
|
256
252
|
],
|
|
257
253
|
routing_profile: 'walking',
|
|
258
254
|
walking_speed: 0.1
|
|
@@ -262,8 +258,8 @@ describe('DirectionsTool', () => {
|
|
|
262
258
|
// Test with value above maximum (6.94 m/s)
|
|
263
259
|
await expect(tool.run({
|
|
264
260
|
coordinates: [
|
|
265
|
-
|
|
266
|
-
|
|
261
|
+
[-73.989, 40.733],
|
|
262
|
+
[-73.979, 40.743]
|
|
267
263
|
],
|
|
268
264
|
routing_profile: 'walking',
|
|
269
265
|
walking_speed: 7.5
|
|
@@ -274,8 +270,8 @@ describe('DirectionsTool', () => {
|
|
|
274
270
|
const mockFetch = setupFetch();
|
|
275
271
|
await tool.run({
|
|
276
272
|
coordinates: [
|
|
277
|
-
|
|
278
|
-
|
|
273
|
+
[-73.989, 40.733],
|
|
274
|
+
[-73.979, 40.743]
|
|
279
275
|
],
|
|
280
276
|
routing_profile: 'walking',
|
|
281
277
|
walking_speed: 3.0
|
|
@@ -288,8 +284,8 @@ describe('DirectionsTool', () => {
|
|
|
288
284
|
// Test with value below minimum (-1)
|
|
289
285
|
await expect(tool.run({
|
|
290
286
|
coordinates: [
|
|
291
|
-
|
|
292
|
-
|
|
287
|
+
[-73.989, 40.733],
|
|
288
|
+
[-73.979, 40.743]
|
|
293
289
|
],
|
|
294
290
|
routing_profile: 'walking',
|
|
295
291
|
walkway_bias: -1.5
|
|
@@ -299,8 +295,8 @@ describe('DirectionsTool', () => {
|
|
|
299
295
|
// Test with value above maximum (1)
|
|
300
296
|
await expect(tool.run({
|
|
301
297
|
coordinates: [
|
|
302
|
-
|
|
303
|
-
|
|
298
|
+
[-73.989, 40.733],
|
|
299
|
+
[-73.979, 40.743]
|
|
304
300
|
],
|
|
305
301
|
routing_profile: 'walking',
|
|
306
302
|
walkway_bias: 1.2
|
|
@@ -311,8 +307,8 @@ describe('DirectionsTool', () => {
|
|
|
311
307
|
const mockFetch = setupFetch();
|
|
312
308
|
await tool.run({
|
|
313
309
|
coordinates: [
|
|
314
|
-
|
|
315
|
-
|
|
310
|
+
[-73.989, 40.733],
|
|
311
|
+
[-73.979, 40.743]
|
|
316
312
|
],
|
|
317
313
|
routing_profile: 'walking',
|
|
318
314
|
walkway_bias: -0.5
|
|
@@ -328,8 +324,8 @@ describe('DirectionsTool', () => {
|
|
|
328
324
|
// Test with driving profile
|
|
329
325
|
await expect(tool.run({
|
|
330
326
|
coordinates: [
|
|
331
|
-
|
|
332
|
-
|
|
327
|
+
[-73.989, 40.733],
|
|
328
|
+
[-73.979, 40.743]
|
|
333
329
|
],
|
|
334
330
|
routing_profile: 'driving',
|
|
335
331
|
exclude: 'toll,motorway,unpaved'
|
|
@@ -339,8 +335,8 @@ describe('DirectionsTool', () => {
|
|
|
339
335
|
// Test with driving-traffic profile
|
|
340
336
|
await expect(tool.run({
|
|
341
337
|
coordinates: [
|
|
342
|
-
|
|
343
|
-
|
|
338
|
+
[-73.989, 40.733],
|
|
339
|
+
[-73.979, 40.743]
|
|
344
340
|
],
|
|
345
341
|
routing_profile: 'driving-traffic',
|
|
346
342
|
exclude: 'tunnel,country_border,state_border'
|
|
@@ -353,8 +349,8 @@ describe('DirectionsTool', () => {
|
|
|
353
349
|
// Test with walking profile
|
|
354
350
|
await expect(tool.run({
|
|
355
351
|
coordinates: [
|
|
356
|
-
|
|
357
|
-
|
|
352
|
+
[-73.989, 40.733],
|
|
353
|
+
[-73.979, 40.743]
|
|
358
354
|
],
|
|
359
355
|
routing_profile: 'walking',
|
|
360
356
|
exclude: 'toll'
|
|
@@ -364,8 +360,8 @@ describe('DirectionsTool', () => {
|
|
|
364
360
|
// Test with cycling profile
|
|
365
361
|
await expect(tool.run({
|
|
366
362
|
coordinates: [
|
|
367
|
-
|
|
368
|
-
|
|
363
|
+
[-73.989, 40.733],
|
|
364
|
+
[-73.979, 40.743]
|
|
369
365
|
],
|
|
370
366
|
routing_profile: 'cycling',
|
|
371
367
|
exclude: 'motorway'
|
|
@@ -379,8 +375,8 @@ describe('DirectionsTool', () => {
|
|
|
379
375
|
// Test with driving profile
|
|
380
376
|
await expect(tool.run({
|
|
381
377
|
coordinates: [
|
|
382
|
-
|
|
383
|
-
|
|
378
|
+
[-73.989, 40.733],
|
|
379
|
+
[-73.979, 40.743]
|
|
384
380
|
],
|
|
385
381
|
routing_profile: 'driving',
|
|
386
382
|
exclude: 'ferry'
|
|
@@ -390,8 +386,8 @@ describe('DirectionsTool', () => {
|
|
|
390
386
|
// Test with walking profile
|
|
391
387
|
await expect(tool.run({
|
|
392
388
|
coordinates: [
|
|
393
|
-
|
|
394
|
-
|
|
389
|
+
[-73.989, 40.733],
|
|
390
|
+
[-73.979, 40.743]
|
|
395
391
|
],
|
|
396
392
|
routing_profile: 'walking',
|
|
397
393
|
exclude: 'ferry'
|
|
@@ -401,8 +397,8 @@ describe('DirectionsTool', () => {
|
|
|
401
397
|
// Test with cycling profile
|
|
402
398
|
await expect(tool.run({
|
|
403
399
|
coordinates: [
|
|
404
|
-
|
|
405
|
-
|
|
400
|
+
[-73.989, 40.733],
|
|
401
|
+
[-73.979, 40.743]
|
|
406
402
|
],
|
|
407
403
|
routing_profile: 'cycling',
|
|
408
404
|
exclude: 'cash_only_tolls'
|
|
@@ -416,8 +412,8 @@ describe('DirectionsTool', () => {
|
|
|
416
412
|
// Test with driving profile - should work
|
|
417
413
|
await expect(tool.run({
|
|
418
414
|
coordinates: [
|
|
419
|
-
|
|
420
|
-
|
|
415
|
+
[-73.989, 40.733],
|
|
416
|
+
[-73.979, 40.743]
|
|
421
417
|
],
|
|
422
418
|
routing_profile: 'driving',
|
|
423
419
|
exclude: 'point(-73.95 40.75)'
|
|
@@ -427,8 +423,8 @@ describe('DirectionsTool', () => {
|
|
|
427
423
|
// Test with walking profile - should fail
|
|
428
424
|
await expect(tool.run({
|
|
429
425
|
coordinates: [
|
|
430
|
-
|
|
431
|
-
|
|
426
|
+
[-73.989, 40.733],
|
|
427
|
+
[-73.979, 40.743]
|
|
432
428
|
],
|
|
433
429
|
routing_profile: 'walking',
|
|
434
430
|
exclude: 'point(-73.95 40.75)'
|
|
@@ -438,8 +434,8 @@ describe('DirectionsTool', () => {
|
|
|
438
434
|
// Test with cycling profile - should fail
|
|
439
435
|
await expect(tool.run({
|
|
440
436
|
coordinates: [
|
|
441
|
-
|
|
442
|
-
|
|
437
|
+
[-73.989, 40.733],
|
|
438
|
+
[-73.979, 40.743]
|
|
443
439
|
],
|
|
444
440
|
routing_profile: 'cycling',
|
|
445
441
|
exclude: 'point(-73.95 40.75)'
|
|
@@ -453,8 +449,8 @@ describe('DirectionsTool', () => {
|
|
|
453
449
|
// All valid exclusions for driving profile
|
|
454
450
|
await expect(tool.run({
|
|
455
451
|
coordinates: [
|
|
456
|
-
|
|
457
|
-
|
|
452
|
+
[-73.989, 40.733],
|
|
453
|
+
[-73.979, 40.743]
|
|
458
454
|
],
|
|
459
455
|
routing_profile: 'driving',
|
|
460
456
|
exclude: 'toll,motorway,ferry,cash_only_tolls,point(-73.95 40.75)'
|
|
@@ -464,8 +460,8 @@ describe('DirectionsTool', () => {
|
|
|
464
460
|
// Mixed valid and invalid exclusions (ferry is valid for walking, toll is not)
|
|
465
461
|
await expect(tool.run({
|
|
466
462
|
coordinates: [
|
|
467
|
-
|
|
468
|
-
|
|
463
|
+
[-73.989, 40.733],
|
|
464
|
+
[-73.979, 40.743]
|
|
469
465
|
],
|
|
470
466
|
routing_profile: 'walking',
|
|
471
467
|
exclude: 'ferry,toll'
|
|
@@ -475,8 +471,8 @@ describe('DirectionsTool', () => {
|
|
|
475
471
|
// All valid exclusions for cycling profile
|
|
476
472
|
await expect(tool.run({
|
|
477
473
|
coordinates: [
|
|
478
|
-
|
|
479
|
-
|
|
474
|
+
[-73.989, 40.733],
|
|
475
|
+
[-73.979, 40.743]
|
|
480
476
|
],
|
|
481
477
|
routing_profile: 'cycling',
|
|
482
478
|
exclude: 'ferry,cash_only_tolls'
|
|
@@ -493,8 +489,8 @@ describe('DirectionsTool', () => {
|
|
|
493
489
|
// Test with driving profile
|
|
494
490
|
await expect(tool.run({
|
|
495
491
|
coordinates: [
|
|
496
|
-
|
|
497
|
-
|
|
492
|
+
[-73.989, 40.733],
|
|
493
|
+
[-73.979, 40.743]
|
|
498
494
|
],
|
|
499
495
|
routing_profile: 'driving',
|
|
500
496
|
depart_at: validDateTime
|
|
@@ -506,8 +502,8 @@ describe('DirectionsTool', () => {
|
|
|
506
502
|
// Test with driving-traffic profile
|
|
507
503
|
await expect(tool.run({
|
|
508
504
|
coordinates: [
|
|
509
|
-
|
|
510
|
-
|
|
505
|
+
[-73.989, 40.733],
|
|
506
|
+
[-73.979, 40.743]
|
|
511
507
|
],
|
|
512
508
|
routing_profile: 'driving-traffic',
|
|
513
509
|
depart_at: validDateTime
|
|
@@ -524,8 +520,8 @@ describe('DirectionsTool', () => {
|
|
|
524
520
|
// Test with driving profile
|
|
525
521
|
await expect(tool.run({
|
|
526
522
|
coordinates: [
|
|
527
|
-
|
|
528
|
-
|
|
523
|
+
[-73.989, 40.733],
|
|
524
|
+
[-73.979, 40.743]
|
|
529
525
|
],
|
|
530
526
|
routing_profile: 'driving',
|
|
531
527
|
max_height: 4.5,
|
|
@@ -541,8 +537,8 @@ describe('DirectionsTool', () => {
|
|
|
541
537
|
// Test with driving-traffic profile
|
|
542
538
|
await expect(tool.run({
|
|
543
539
|
coordinates: [
|
|
544
|
-
|
|
545
|
-
|
|
540
|
+
[-73.989, 40.733],
|
|
541
|
+
[-73.979, 40.743]
|
|
546
542
|
],
|
|
547
543
|
routing_profile: 'driving-traffic',
|
|
548
544
|
max_height: 3.2
|
|
@@ -557,8 +553,8 @@ describe('DirectionsTool', () => {
|
|
|
557
553
|
// Test with walking profile
|
|
558
554
|
await expect(tool.run({
|
|
559
555
|
coordinates: [
|
|
560
|
-
|
|
561
|
-
|
|
556
|
+
[-73.989, 40.733],
|
|
557
|
+
[-73.979, 40.743]
|
|
562
558
|
],
|
|
563
559
|
routing_profile: 'walking',
|
|
564
560
|
max_height: 4.5
|
|
@@ -568,8 +564,8 @@ describe('DirectionsTool', () => {
|
|
|
568
564
|
// Test with cycling profile
|
|
569
565
|
await expect(tool.run({
|
|
570
566
|
coordinates: [
|
|
571
|
-
|
|
572
|
-
|
|
567
|
+
[-73.989, 40.733],
|
|
568
|
+
[-73.979, 40.743]
|
|
573
569
|
],
|
|
574
570
|
routing_profile: 'cycling',
|
|
575
571
|
max_width: 2.0
|
|
@@ -582,8 +578,8 @@ describe('DirectionsTool', () => {
|
|
|
582
578
|
// Test invalid height (too high)
|
|
583
579
|
await expect(tool.run({
|
|
584
580
|
coordinates: [
|
|
585
|
-
|
|
586
|
-
|
|
581
|
+
[-73.989, 40.733],
|
|
582
|
+
[-73.979, 40.743]
|
|
587
583
|
],
|
|
588
584
|
routing_profile: 'driving',
|
|
589
585
|
max_height: 15.0
|
|
@@ -593,8 +589,8 @@ describe('DirectionsTool', () => {
|
|
|
593
589
|
// Test invalid width (negative)
|
|
594
590
|
await expect(tool.run({
|
|
595
591
|
coordinates: [
|
|
596
|
-
|
|
597
|
-
|
|
592
|
+
[-73.989, 40.733],
|
|
593
|
+
[-73.979, 40.743]
|
|
598
594
|
],
|
|
599
595
|
routing_profile: 'driving',
|
|
600
596
|
max_width: -1.0
|
|
@@ -604,8 +600,8 @@ describe('DirectionsTool', () => {
|
|
|
604
600
|
// Test invalid weight (too heavy)
|
|
605
601
|
await expect(tool.run({
|
|
606
602
|
coordinates: [
|
|
607
|
-
|
|
608
|
-
|
|
603
|
+
[-73.989, 40.733],
|
|
604
|
+
[-73.979, 40.743]
|
|
609
605
|
],
|
|
610
606
|
routing_profile: 'driving',
|
|
611
607
|
max_weight: 150.0
|
|
@@ -620,8 +616,8 @@ describe('DirectionsTool', () => {
|
|
|
620
616
|
// Test with walking profile
|
|
621
617
|
await expect(tool.run({
|
|
622
618
|
coordinates: [
|
|
623
|
-
|
|
624
|
-
|
|
619
|
+
[-73.989, 40.733],
|
|
620
|
+
[-73.979, 40.743]
|
|
625
621
|
],
|
|
626
622
|
routing_profile: 'walking',
|
|
627
623
|
depart_at: validDateTime
|
|
@@ -631,8 +627,8 @@ describe('DirectionsTool', () => {
|
|
|
631
627
|
// Test with cycling profile
|
|
632
628
|
await expect(tool.run({
|
|
633
629
|
coordinates: [
|
|
634
|
-
|
|
635
|
-
|
|
630
|
+
[-73.989, 40.733],
|
|
631
|
+
[-73.979, 40.743]
|
|
636
632
|
],
|
|
637
633
|
routing_profile: 'cycling',
|
|
638
634
|
depart_at: validDateTime
|
|
@@ -644,8 +640,8 @@ describe('DirectionsTool', () => {
|
|
|
644
640
|
const mockFetch = setupFetch();
|
|
645
641
|
const tool = new DirectionsTool();
|
|
646
642
|
const baseCoordinates = [
|
|
647
|
-
|
|
648
|
-
|
|
643
|
+
[-73.989, 40.733],
|
|
644
|
+
[-73.979, 40.743]
|
|
649
645
|
];
|
|
650
646
|
// Format 1: YYYY-MM-DDThh:mm:ssZ
|
|
651
647
|
await expect(tool.run({
|
|
@@ -672,8 +668,8 @@ describe('DirectionsTool', () => {
|
|
|
672
668
|
it('rejects invalid date-time formats', async () => {
|
|
673
669
|
const tool = new DirectionsTool();
|
|
674
670
|
const baseCoordinates = [
|
|
675
|
-
|
|
676
|
-
|
|
671
|
+
[-73.989, 40.733],
|
|
672
|
+
[-73.979, 40.743]
|
|
677
673
|
];
|
|
678
674
|
// Invalid format examples
|
|
679
675
|
const invalidFormats = [
|
|
@@ -699,8 +695,8 @@ describe('DirectionsTool', () => {
|
|
|
699
695
|
it('rejects dates with invalid components', async () => {
|
|
700
696
|
const tool = new DirectionsTool();
|
|
701
697
|
const baseCoordinates = [
|
|
702
|
-
|
|
703
|
-
|
|
698
|
+
[-73.989, 40.733],
|
|
699
|
+
[-73.979, 40.743]
|
|
704
700
|
];
|
|
705
701
|
// Invalid time components
|
|
706
702
|
const invalidDates = [
|
|
@@ -727,8 +723,8 @@ describe('DirectionsTool', () => {
|
|
|
727
723
|
// Test with driving profile - should work
|
|
728
724
|
await new DirectionsTool().run({
|
|
729
725
|
coordinates: [
|
|
730
|
-
|
|
731
|
-
|
|
726
|
+
[-74.1, 40.7],
|
|
727
|
+
[-74.2, 40.8]
|
|
732
728
|
],
|
|
733
729
|
routing_profile: 'driving',
|
|
734
730
|
arrive_by: validDateTime
|
|
@@ -742,8 +738,8 @@ describe('DirectionsTool', () => {
|
|
|
742
738
|
// Test with driving-traffic profile
|
|
743
739
|
const result1 = await new DirectionsTool().run({
|
|
744
740
|
coordinates: [
|
|
745
|
-
|
|
746
|
-
|
|
741
|
+
[-74.1, 40.7],
|
|
742
|
+
[-74.2, 40.8]
|
|
747
743
|
],
|
|
748
744
|
routing_profile: 'driving-traffic',
|
|
749
745
|
arrive_by: validDateTime
|
|
@@ -752,8 +748,8 @@ describe('DirectionsTool', () => {
|
|
|
752
748
|
// Test with walking profile
|
|
753
749
|
const result2 = await new DirectionsTool().run({
|
|
754
750
|
coordinates: [
|
|
755
|
-
|
|
756
|
-
|
|
751
|
+
[-74.1, 40.7],
|
|
752
|
+
[-74.2, 40.8]
|
|
757
753
|
],
|
|
758
754
|
routing_profile: 'walking',
|
|
759
755
|
arrive_by: validDateTime
|
|
@@ -762,8 +758,8 @@ describe('DirectionsTool', () => {
|
|
|
762
758
|
// Test with cycling profile
|
|
763
759
|
const result3 = await new DirectionsTool().run({
|
|
764
760
|
coordinates: [
|
|
765
|
-
|
|
766
|
-
|
|
761
|
+
[-74.1, 40.7],
|
|
762
|
+
[-74.2, 40.8]
|
|
767
763
|
],
|
|
768
764
|
routing_profile: 'cycling',
|
|
769
765
|
arrive_by: validDateTime
|
|
@@ -773,8 +769,8 @@ describe('DirectionsTool', () => {
|
|
|
773
769
|
it('rejects when both arrive_by and depart_at are provided', async () => {
|
|
774
770
|
const result = await new DirectionsTool().run({
|
|
775
771
|
coordinates: [
|
|
776
|
-
|
|
777
|
-
|
|
772
|
+
[-74.1, 40.7],
|
|
773
|
+
[-74.2, 40.8]
|
|
778
774
|
],
|
|
779
775
|
routing_profile: 'driving',
|
|
780
776
|
depart_at: '2025-06-05T09:30:00Z',
|
|
@@ -787,8 +783,8 @@ describe('DirectionsTool', () => {
|
|
|
787
783
|
// Test with Z format
|
|
788
784
|
await new DirectionsTool().run({
|
|
789
785
|
coordinates: [
|
|
790
|
-
|
|
791
|
-
|
|
786
|
+
[-74.1, 40.7],
|
|
787
|
+
[-74.2, 40.8]
|
|
792
788
|
],
|
|
793
789
|
routing_profile: 'driving',
|
|
794
790
|
arrive_by: '2025-06-05T10:30:00Z'
|
|
@@ -798,8 +794,8 @@ describe('DirectionsTool', () => {
|
|
|
798
794
|
// Test with timezone offset format
|
|
799
795
|
await new DirectionsTool().run({
|
|
800
796
|
coordinates: [
|
|
801
|
-
|
|
802
|
-
|
|
797
|
+
[-74.1, 40.7],
|
|
798
|
+
[-74.2, 40.8]
|
|
803
799
|
],
|
|
804
800
|
routing_profile: 'driving',
|
|
805
801
|
arrive_by: '2025-06-05T10:30:00+02:00'
|
|
@@ -809,8 +805,8 @@ describe('DirectionsTool', () => {
|
|
|
809
805
|
// Test with simple time format (no seconds, no timezone)
|
|
810
806
|
await new DirectionsTool().run({
|
|
811
807
|
coordinates: [
|
|
812
|
-
|
|
813
|
-
|
|
808
|
+
[-74.1, 40.7],
|
|
809
|
+
[-74.2, 40.8]
|
|
814
810
|
],
|
|
815
811
|
routing_profile: 'driving',
|
|
816
812
|
arrive_by: '2025-06-05T10:30'
|
|
@@ -836,8 +832,8 @@ describe('DirectionsTool', () => {
|
|
|
836
832
|
for (const format of invalidFormats) {
|
|
837
833
|
const result = await new DirectionsTool().run({
|
|
838
834
|
coordinates: [
|
|
839
|
-
|
|
840
|
-
|
|
835
|
+
[-74.1, 40.7],
|
|
836
|
+
[-74.2, 40.8]
|
|
841
837
|
],
|
|
842
838
|
routing_profile: 'driving',
|
|
843
839
|
arrive_by: format
|
|
@@ -857,8 +853,8 @@ describe('DirectionsTool', () => {
|
|
|
857
853
|
for (const date of invalidDates) {
|
|
858
854
|
const result = await new DirectionsTool().run({
|
|
859
855
|
coordinates: [
|
|
860
|
-
|
|
861
|
-
|
|
856
|
+
[-74.1, 40.7],
|
|
857
|
+
[-74.2, 40.8]
|
|
862
858
|
],
|
|
863
859
|
routing_profile: 'driving',
|
|
864
860
|
arrive_by: date
|