import { describe, it, expect } from 'vitest';
import { analyzeMessages } from '../analyzer.js';

describe('analyzeMessages', () => {
  it('classifies user messages', () => {
    const breakdown = analyzeMessages([{ role: 'user', content: 'hello world' }]);
    expect(breakdown.user).toBeGreaterThan(0);
    expect(breakdown.total).toBe(breakdown.user);
  });

  it('counts tool calls', () => {
    const parts = [
      { role: 'assistant', content: 'using grep', tool_calls: [{ id: '1', name: 'grep', arguments: '{}' }] },
      { role: 'tool', content: '{"files":[]}', tool_call_id: '1' },
    ];
    const breakdown = analyzeMessages(parts);
    expect(breakdown.tools).toBeGreaterThan(0);
    expect(breakdown.assistant).toBeGreaterThan(0);
  });

  it('separates reasoning tokens', () => {
    const parts = [
      { role: 'assistant', content: 'short answer', reasoning_parts: [{ text: 'long chain of thought reasoning here' }] },
    ];
    const breakdown = analyzeMessages(parts);
    expect(breakdown.reasoning).toBeGreaterThan(0);
    expect(breakdown.assistant).toBeLessThan(breakdown.reasoning);
  });
});
