"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
    var ownKeys = function(o) {
        ownKeys = Object.getOwnPropertyNames || function (o) {
            var ar = [];
            for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
            return ar;
        };
        return ownKeys(o);
    };
    return function (mod) {
        if (mod && mod.__esModule) return mod;
        var result = {};
        if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
        __setModuleDefault(result, mod);
        return result;
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
const solution_index_1 = require("../solution-index");
const path = __importStar(require("path"));
describe('SolutionIndex', () => {
    let index;
    const testDir = path.join(process.cwd(), '.fivo/cell');
    beforeEach(() => {
        index = new solution_index_1.SolutionIndex(testDir);
        index.clear();
    });
    test('adds and searches solutions', () => {
        index.addSolution('Auth Middleware', 'JWT-based auth middleware for Express', ['express', 'jwt'], 'project-a', ['auth', 'middleware'], 'code...');
        const results = index.search('auth');
        expect(results.length).toBeGreaterThan(0);
        expect(results[0].title).toBe('Auth Middleware');
    });
    test('finds similar solutions', () => {
        index.addSolution('Auth', 'JWT authentication', ['express'], 'p1', ['auth'], '');
        index.addSolution('Login', 'User login system', ['express', 'passport'], 'p2', ['auth', 'login'], '');
        const similar = index.findSimilar('authentication system', ['express']);
        expect(similar.length).toBeGreaterThan(0);
    });
    test('detects cold start', () => {
        expect(index.isColdStart()).toBe(true);
        index.addSolution('S1', 'desc', ['ts'], 'p1', ['tag'], '');
        index.addSolution('S2', 'desc', ['ts'], 'p1', ['tag'], '');
        index.addSolution('S3', 'desc', ['ts'], 'p1', ['tag'], '');
        index.addSolution('S4', 'desc', ['ts'], 'p1', ['tag'], '');
        index.addSolution('S5', 'desc', ['ts'], 'p1', ['tag'], '');
        index.addSolution('S6', 'desc', ['ts'], 'p2', ['tag'], '');
        index.addSolution('S7', 'desc', ['ts'], 'p2', ['tag'], '');
        index.addSolution('S8', 'desc', ['ts'], 'p2', ['tag'], '');
        index.addSolution('S9', 'desc', ['ts'], 'p2', ['tag'], '');
        index.addSolution('S10', 'desc', ['ts'], 'p2', ['tag'], '');
        expect(index.isColdStart()).toBe(false);
    });
    test('getStats returns correct structure', () => {
        index.addSolution('Test', 'desc', ['ts'], 'p1', ['tag'], '');
        const stats = index.getStats();
        expect(stats.projects).toBe(1);
        expect(stats.totalSolutions).toBe(1);
    });
});
//# sourceMappingURL=solution-index.test.js.map