"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 context_restore_1 = require("../context-restore");
const path = __importStar(require("path"));
describe('ContextRestore', () => {
    let restore;
    const testDir = path.join(process.cwd(), '.fivo/cell');
    beforeEach(() => {
        restore = new context_restore_1.ContextRestore(testDir);
    });
    test('captures and restores snapshot', () => {
        restore.capture('test-project', ['file1.ts', 'file2.ts'], 'file1.ts', 42, ['Fix bug', 'Add test'], 'Working on auth', 'feature/auth');
        const snapshot = restore.restore('test-project');
        expect(snapshot).not.toBeNull();
        expect(snapshot.projectId).toBe('test-project');
        expect(snapshot.openFiles).toHaveLength(2);
        expect(snapshot.cursorLine).toBe(42);
    });
    test('returns null for missing project', () => {
        const snapshot = restore.restore('nonexistent');
        expect(snapshot).toBeNull();
    });
    test('getResumePrompt formats correctly', () => {
        restore.capture('proj', ['a.ts'], 'a.ts', 10, [], '', 'main');
        const snapshot = restore.restore('proj');
        const prompt = restore.getResumePrompt(snapshot);
        expect(prompt).toContain('Resume proj');
        expect(prompt).toContain('a.ts:10');
    });
    test('getAllSnapshots returns all', () => {
        restore.capture('p1_getall', [], '', 0, [], '', 'main');
        restore.capture('p2_getall', [], '', 0, [], '', 'main');
        const all = restore.getAllSnapshots();
        expect(all.filter((s) => s.projectId.includes('getall'))).toHaveLength(2);
    });
    test('clear removes snapshot', () => {
        restore.capture('temp', [], '', 0, [], '', 'main');
        restore.clear('temp');
        expect(restore.restore('temp')).toBeNull();
    });
});
//# sourceMappingURL=context-restore.test.js.map