Skip to content

Commit 7fbe9ae

Browse files
committed
test: review updates
1 parent 10733a2 commit 7fbe9ae

File tree

3 files changed

+234
-238
lines changed

3 files changed

+234
-238
lines changed

src/__tests__/__snapshots__/server.toolsUser.test.ts.snap

Lines changed: 71 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,6 @@ exports[`createMcpTool should normalize configs, single tuple 1`] = `
4646
]
4747
`;
4848

49-
exports[`createMcpTool should throw an error, packages, mix of non-configs 1`] = `"createMcpTool: invalid configuration used at index 3: Unsupported type number"`;
50-
51-
exports[`createMcpTool should throw an error, undefined 1`] = `"createMcpTool: invalid configuration used at index 1: Unsupported type undefined"`;
52-
5349
exports[`normalizeFilePackage handles absolute file path 1`] = `
5450
{
5551
"fsReadDir": "/",
@@ -76,6 +72,39 @@ exports[`normalizeFilePackage handles file URL 1`] = `
7672
}
7773
`;
7874

75+
exports[`normalizeFilePackage handles http URL (not file) 1`] = `
76+
{
77+
"fsReadDir": "/",
78+
"isFilePath": true,
79+
"isFileUrl": false,
80+
"isUrlLike": true,
81+
"normalizedUrl": "/module.mjs",
82+
"original": "/module.mjs",
83+
"type": "package",
84+
"value": "/module.mjs",
85+
}
86+
`;
87+
88+
exports[`normalizeFilePackage handles invalid file URLs, encoding 1`] = `
89+
{
90+
"error": "true",
91+
"fsReadDir": "/",
92+
"isFilePath": false,
93+
"isFileUrl": true,
94+
"isUrlLike": true,
95+
"normalizedUrl": "/%E0%A4%A",
96+
"original": "/%E0%A4%A",
97+
"type": "invalid",
98+
"value": "/%E0%A4%A",
99+
}
100+
`;
101+
102+
exports[`normalizeFilePackage handles invalid file URLs, hostname 1`] = `undefined`;
103+
104+
exports[`normalizeFilePackage handles null 1`] = `undefined`;
105+
106+
exports[`normalizeFilePackage handles number 1`] = `undefined`;
107+
79108
exports[`normalizeFilePackage handles package name string 1`] = `
80109
{
81110
"fsReadDir": "/",
@@ -102,6 +131,8 @@ exports[`normalizeFilePackage handles relative file path 1`] = `
102131
}
103132
`;
104133

134+
exports[`normalizeFilePackage handles undefined 1`] = `undefined`;
135+
105136
exports[`normalizeFilePath handles absolute file path 1`] = `
106137
{
107138
"fsReadDir": "/",
@@ -115,18 +146,7 @@ exports[`normalizeFilePath handles absolute file path 1`] = `
115146
}
116147
`;
117148

118-
exports[`normalizeFilePath handles file URL 1`] = `
119-
{
120-
"fsReadDir": "/",
121-
"isFilePath": true,
122-
"isFileUrl": true,
123-
"isUrlLike": true,
124-
"normalizedUrl": "/package.json",
125-
"original": "/package.json",
126-
"type": "file",
127-
"value": "/package.json",
128-
}
129-
`;
149+
exports[`normalizeFilePath handles file URL 1`] = `undefined`;
130150

131151
exports[`normalizeFilePath handles package name string 1`] = `undefined`;
132152

@@ -158,6 +178,24 @@ exports[`normalizeFileUrl handles file URL 1`] = `
158178
}
159179
`;
160180

181+
exports[`normalizeFileUrl handles http URL (not file) 1`] = `undefined`;
182+
183+
exports[`normalizeFileUrl handles invalid file URLs, encoding 1`] = `
184+
{
185+
"error": "true",
186+
"fsReadDir": "/",
187+
"isFilePath": false,
188+
"isFileUrl": true,
189+
"isUrlLike": true,
190+
"normalizedUrl": "/%E0%A4%A",
191+
"original": "/%E0%A4%A",
192+
"type": "invalid",
193+
"value": "/%E0%A4%A",
194+
}
195+
`;
196+
197+
exports[`normalizeFileUrl handles invalid file URLs, hostname 1`] = `undefined`;
198+
161199
exports[`normalizeFileUrl handles package name string 1`] = `undefined`;
162200

163201
exports[`normalizeFileUrl handles relative file path 1`] = `undefined`;
@@ -265,10 +303,8 @@ exports[`normalizeTools should normalize configs, a creator 1`] = `
265303
[
266304
{
267305
"index": 0,
268-
"original": [Function],
269306
"toolName": undefined,
270307
"type": "creator",
271-
"value": [Function],
272308
},
273309
]
274310
`;
@@ -277,18 +313,8 @@ exports[`normalizeTools should normalize configs, an object 1`] = `
277313
[
278314
{
279315
"index": 0,
280-
"original": {
281-
"description": "lorem ipsum",
282-
"handler": [Function],
283-
"inputSchema": {
284-
"properties": {},
285-
"type": "object",
286-
},
287-
"name": "loremIpsum",
288-
},
289316
"toolName": "loremIpsum",
290317
"type": "object",
291-
"value": [Function],
292318
},
293319
]
294320
`;
@@ -297,128 +323,78 @@ exports[`normalizeTools should normalize configs, array of creators 1`] = `
297323
[
298324
{
299325
"index": 0,
300-
"original": [Function],
301326
"toolName": undefined,
302327
"type": "creator",
303-
"value": [Function],
304328
},
305329
{
306330
"index": 1,
307-
"original": [Function],
308331
"toolName": undefined,
309332
"type": "creator",
310-
"value": [Function],
311333
},
312334
]
313335
`;
314336

315-
exports[`normalizeTools should normalize configs, mix of non-configs 1`] = `
337+
exports[`normalizeTools should normalize configs, invalid file URLs, hostname, encoding 1`] = `
316338
[
317339
{
318-
"error": "createMcpTool: invalid configuration used at index 0: Unsupported type object",
319340
"index": 0,
320-
"original": null,
341+
"toolName": undefined,
321342
"type": "invalid",
322-
"value": "createMcpTool: invalid configuration used at index 0: Unsupported type object",
323343
},
324344
{
325-
"error": "createMcpTool: invalid configuration used at index 1: Unsupported type undefined",
326345
"index": 1,
327-
"original": undefined,
328-
"type": "invalid",
329-
"value": "createMcpTool: invalid configuration used at index 1: Unsupported type undefined",
330-
},
331-
{
332-
"error": "createMcpTool: invalid configuration used at index 2: Unsupported type object",
333-
"index": 2,
334-
"original": {
335-
"x": 1,
336-
},
346+
"toolName": undefined,
337347
"type": "invalid",
338-
"value": "createMcpTool: invalid configuration used at index 2: Unsupported type object",
339348
},
349+
]
350+
`;
351+
352+
exports[`normalizeTools should normalize configs, mix of non-configs 1`] = `
353+
[
340354
{
341-
"error": "createMcpTool: invalid configuration used at index 3: Unsupported type number",
342-
"index": 3,
343-
"original": 1,
355+
"index": 0,
356+
"toolName": undefined,
344357
"type": "invalid",
345-
"value": "createMcpTool: invalid configuration used at index 3: Unsupported type number",
346358
},
347359
{
348-
"error": "createMcpTool: invalid configuration used at index 4: Unsupported type number",
349-
"index": 4,
350-
"original": 2,
360+
"index": 1,
361+
"toolName": undefined,
351362
"type": "invalid",
352-
"value": "createMcpTool: invalid configuration used at index 4: Unsupported type number",
353363
},
354364
{
355-
"error": "createMcpTool: invalid configuration used at index 5: Unsupported type number",
356-
"index": 5,
357-
"original": 3,
365+
"index": 2,
366+
"toolName": undefined,
358367
"type": "invalid",
359-
"value": "createMcpTool: invalid configuration used at index 5: Unsupported type number",
360368
},
361369
{
362-
"error": "createMcpTool: invalid configuration used at index 6: Unsupported type object",
363-
"index": 6,
364-
"original": [Error: lorem ipsum],
370+
"index": 3,
371+
"toolName": undefined,
365372
"type": "invalid",
366-
"value": "createMcpTool: invalid configuration used at index 6: Unsupported type object",
367373
},
368374
]
369375
`;
370376

371377
exports[`normalizeTools should normalize configs, mix of package, object, tuple, creator 1`] = `
372378
[
373379
{
374-
"fsReadDir": undefined,
375380
"index": 0,
376-
"isFilePath": false,
377-
"isFileUrl": false,
378-
"isUrlLike": false,
379-
"normalizedUrl": "@scope/pkg",
380-
"original": "@scope/pkg",
381+
"toolName": undefined,
381382
"type": "package",
382-
"value": "@scope/pkg",
383383
},
384384
{
385385
"index": 1,
386-
"original": {
387-
"description": "amet dolor",
388-
"handler": [Function],
389-
"inputSchema": {
390-
"properties": {},
391-
"type": "object",
392-
},
393-
"name": "ametDolor",
394-
},
395386
"toolName": "ametDolor",
396387
"type": "object",
397-
"value": [Function],
398388
},
399389
{
400390
"index": 2,
401-
"original": [
402-
"loremIpsum",
403-
{
404-
"description": "lorem ipsum",
405-
"inputSchema": {
406-
"properties": {},
407-
"type": "object",
408-
},
409-
},
410-
[Function],
411-
],
412391
"toolName": "loremIpsum",
413392
"type": "tuple",
414-
"value": [Function],
415393
},
416394
{
417395
"index": 3,
418-
"original": [Function],
419396
"toolName": undefined,
420397
"type": "creator",
421-
"value": [Function],
422398
},
423399
]
424400
`;
@@ -427,20 +403,8 @@ exports[`normalizeTools should normalize configs, single tuple 1`] = `
427403
[
428404
{
429405
"index": 0,
430-
"original": [
431-
"loremIpsum",
432-
{
433-
"description": "lorem ipsum",
434-
"inputSchema": {
435-
"properties": {},
436-
"type": "object",
437-
},
438-
},
439-
[Function],
440-
],
441406
"toolName": "loremIpsum",
442407
"type": "tuple",
443-
"value": [Function],
444408
},
445409
]
446410
`;

0 commit comments

Comments
 (0)