@mhalder/qdrant-mcp-server 2.1.1 → 2.2.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.
@@ -114,8 +114,10 @@ def calculate_average(numbers):
114
114
  if (chunks.length > 0) {
115
115
  expect(
116
116
  chunks.some(
117
- (c) => c.metadata.name === "calculate_sum" || c.metadata.name === "calculate_product"
118
- )
117
+ (c) =>
118
+ c.metadata.name === "calculate_sum" ||
119
+ c.metadata.name === "calculate_product",
120
+ ),
119
121
  ).toBe(true);
120
122
  }
121
123
  });
@@ -170,7 +172,11 @@ function veryLargeFunction() {
170
172
  }
171
173
  `;
172
174
 
173
- const chunks = await chunker.chunk(largeFunction, "test.js", "javascript");
175
+ const chunks = await chunker.chunk(
176
+ largeFunction,
177
+ "test.js",
178
+ "javascript",
179
+ );
174
180
  expect(chunks.length).toBeGreaterThan(0);
175
181
  });
176
182
 
@@ -198,8 +204,13 @@ function myFunction() {
198
204
  });
199
205
 
200
206
  it("should include file path and language", async () => {
201
- const code = "function test() {\n console.log('Test function');\n return true;\n}";
202
- const chunks = await chunker.chunk(code, "/path/to/file.ts", "typescript");
207
+ const code =
208
+ "function test() {\n console.log('Test function');\n return true;\n}";
209
+ const chunks = await chunker.chunk(
210
+ code,
211
+ "/path/to/file.ts",
212
+ "typescript",
213
+ );
203
214
 
204
215
  expect(chunks[0].metadata.filePath).toBe("/path/to/file.ts");
205
216
  expect(chunks[0].metadata.language).toBe("typescript");
@@ -271,5 +282,76 @@ class Outer {
271
282
  const chunks = await chunker.chunk(code, "test.ts", "typescript");
272
283
  expect(chunks.length).toBeGreaterThan(0);
273
284
  });
285
+
286
+ it("should extract name from child identifier when name field is absent", async () => {
287
+ // This code pattern will trigger the fallback name extraction from children
288
+ const code = `
289
+ type MyType = {
290
+ field1: string;
291
+ field2: number;
292
+ };
293
+ `;
294
+
295
+ const chunks = await chunker.chunk(code, "test.ts", "typescript");
296
+ expect(chunks.length).toBeGreaterThanOrEqual(0);
297
+ });
298
+
299
+ it("should handle struct-like constructs", async () => {
300
+ // Go-like struct to test getChunkType handling of struct patterns
301
+ const code = `
302
+ type User struct {
303
+ ID int
304
+ Name string
305
+ }
306
+ `;
307
+
308
+ const chunks = await chunker.chunk(code, "test.go", "go");
309
+ expect(chunks.length).toBeGreaterThanOrEqual(0);
310
+ // Should classify as class type due to struct pattern
311
+ if (chunks.length > 0) {
312
+ expect(chunks.some((c) => c.metadata.chunkType === "class")).toBe(true);
313
+ }
314
+ });
315
+
316
+ it("should handle trait-like constructs", async () => {
317
+ // Rust trait to test getChunkType handling of trait patterns
318
+ const code = `
319
+ trait Printable {
320
+ fn print(&self);
321
+ }
322
+ `;
323
+
324
+ const chunks = await chunker.chunk(code, "test.rs", "rust");
325
+ expect(chunks.length).toBeGreaterThanOrEqual(0);
326
+ // Should classify as interface type due to trait pattern
327
+ if (chunks.length > 0) {
328
+ expect(chunks.some((c) => c.metadata.chunkType === "interface")).toBe(
329
+ true,
330
+ );
331
+ }
332
+ });
333
+
334
+ it("should classify unknown node types as block", async () => {
335
+ // Create a large code block that doesn't match function, class, or interface patterns
336
+ const code = `
337
+ export const myModule = {
338
+ helper1: () => {
339
+ console.log('Helper function 1');
340
+ return 'result1';
341
+ },
342
+ helper2: () => {
343
+ console.log('Helper function 2');
344
+ return 'result2';
345
+ },
346
+ config: {
347
+ name: 'my-module',
348
+ version: '1.0.0',
349
+ },
350
+ };
351
+ `;
352
+
353
+ const chunks = await chunker.chunk(code, "test.ts", "typescript");
354
+ expect(chunks.length).toBeGreaterThanOrEqual(0);
355
+ });
274
356
  });
275
357
  });