GitNexus/gitnexus/test/unit/bm25-search.test.ts
abhigyanpatwari 8a100a76d3 test: add test suite with vitest (unit + integration + fixtures)
- 59 test files covering unit and integration tests
- vitest config with coverage thresholds and fork pooling
- Test fixtures (mini-repo + multi-language sample code)
- Add vitest + coverage-v8 to devDependencies
- Add test scripts (test, test:integration, test:all, test:watch, test:coverage)
- Move typescript to devDependencies where it belongs

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 20:07:02 +05:30

36 lines
1.2 KiB
TypeScript

import { describe, it, expect } from 'vitest';
import { searchFTSFromKuzu, type BM25SearchResult } from '../../src/core/search/bm25-index.js';
describe('BM25 search', () => {
describe('searchFTSFromKuzu', () => {
it('returns empty array when KuzuDB is not initialized', async () => {
// Without KuzuDB init, search should return empty (not crash)
const results = await searchFTSFromKuzu('test query');
expect(Array.isArray(results)).toBe(true);
expect(results).toHaveLength(0);
});
it('handles empty query', async () => {
const results = await searchFTSFromKuzu('');
expect(Array.isArray(results)).toBe(true);
});
it('accepts custom limit parameter', async () => {
const results = await searchFTSFromKuzu('test', 5);
expect(Array.isArray(results)).toBe(true);
});
});
describe('BM25SearchResult type', () => {
it('has correct shape', () => {
const result: BM25SearchResult = {
filePath: 'src/index.ts',
score: 1.5,
rank: 1,
};
expect(result.filePath).toBe('src/index.ts');
expect(result.score).toBe(1.5);
expect(result.rank).toBe(1);
});
});
});