"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const signal_capture_1 = require("../../walls/05-community/share/signal-capture");
describe('SignalCapture', () => {
    let capture;
    const context = {
        language: 'typescript',
        framework: 'react',
        fileType: 'component',
        strictness: 'strict',
        projectId: 'test-project',
    };
    beforeEach(() => {
        capture = new signal_capture_1.SignalCapture(30);
    });
    test('captures edit diff signal with correct weight', () => {
        const signal = capture.captureEditDiff('var x = 1', 'const x = 1', context);
        expect(signal.type).toBe('edit_diff');
        expect(signal.weight).toBe(1.0);
        expect(signal.originalCode).toBe('var x = 1');
        expect(signal.editedCode).toBe('const x = 1');
        expect(signal.context.language).toBe('typescript');
    });
    test('captures accept signal with correct weight', () => {
        const signal = capture.captureAccept('const x = 1', context);
        expect(signal.type).toBe('accept');
        expect(signal.weight).toBe(1.5);
        expect(signal.originalCode).toBe('const x = 1');
        expect(signal.editedCode).toBe('');
    });
    test('captures reject signal with correct weight', () => {
        const signal = capture.captureReject('bad code', context);
        expect(signal.type).toBe('reject');
        expect(signal.weight).toBe(0.5);
        expect(signal.editedCode).toBe('');
    });
    test('captures retry signal with correct weight', () => {
        const signal = capture.captureRetry('meh code', context);
        expect(signal.type).toBe('retry');
        expect(signal.weight).toBe(0.3);
        expect(signal.editedCode).toBe('');
    });
    test('all signals have unique IDs', () => {
        const s1 = capture.captureAccept('code', context);
        const s2 = capture.captureAccept('code', context);
        const s3 = capture.captureAccept('code', context);
        expect(s1.id).not.toBe(s2.id);
        expect(s2.id).not.toBe(s3.id);
        expect(s1.id).not.toBe(s3.id);
    });
    test('signals have timestamps', () => {
        const before = Date.now();
        const signal = capture.captureAccept('code', context);
        const after = Date.now();
        expect(signal.timestamp).toBeGreaterThanOrEqual(before);
        expect(signal.timestamp).toBeLessThanOrEqual(after);
    });
    test('signals share session ID within time window', () => {
        const s1 = capture.captureAccept('code', context);
        const s2 = capture.captureEditDiff('old', 'new', context);
        expect(s1.sessionId).toBe(s2.sessionId);
    });
    test('getAllSignals returns all captured signals', () => {
        capture.captureAccept('code', context);
        capture.captureReject('bad', context);
        capture.captureEditDiff('old', 'new', context);
        expect(capture.getAllSignals()).toHaveLength(3);
    });
    test('getSignalsByType filters correctly', () => {
        capture.captureAccept('code', context);
        capture.captureAccept('code2', context);
        capture.captureReject('bad', context);
        expect(capture.getSignalsByType('accept')).toHaveLength(2);
        expect(capture.getSignalsByType('reject')).toHaveLength(1);
        expect(capture.getSignalsByType('edit_diff')).toHaveLength(0);
    });
    test('getSignalsBySession filters by session', () => {
        const s1 = capture.captureAccept('code', context);
        const sessionId = s1.sessionId;
        capture.captureReject('bad', context);
        expect(capture.getSignalsBySession(sessionId)).toHaveLength(2);
    });
    test('getSignalCount returns correct count', () => {
        expect(capture.getSignalCount()).toBe(0);
        capture.captureAccept('code', context);
        expect(capture.getSignalCount()).toBe(1);
        capture.captureReject('bad', context);
        expect(capture.getSignalCount()).toBe(2);
    });
    test('clear removes all signals', () => {
        capture.captureAccept('code', context);
        capture.captureReject('bad', context);
        expect(capture.getSignalCount()).toBe(2);
        capture.clear();
        expect(capture.getSignalCount()).toBe(0);
    });
});
//# sourceMappingURL=signal-capture.test.js.map