import { describe, expect, it } from 'vitest';

import { NbaStrategy } from '../nba.strategy';

describe('NbaStrategy', () => {
  it('keeps raw grok confidence when rag is the only extra available signal', () => {
    const strategy = new NbaStrategy();

    const composite = strategy.computeComposite([
      {
        signalId: 'grok',
        score: 0.6,
        weight: 0.3,
        available: true,
        rawData: {},
        metadata: { latencyMs: 0, source: 'api', freshness: '2026-03-29T00:00:00.000Z' },
      },
      {
        signalId: 'rag',
        score: 0.509,
        weight: 0.07,
        available: true,
        rawData: {},
        metadata: { latencyMs: 0, source: 'api', freshness: '2026-03-29T00:00:00.000Z' },
      },
      {
        signalId: 'piff',
        score: 0.5,
        weight: 0.3,
        available: false,
        rawData: {},
        metadata: { latencyMs: 0, source: 'file', freshness: '2026-03-29' },
      },
      {
        signalId: 'digimon',
        score: 0.5,
        weight: 0.25,
        available: false,
        rawData: {},
        metadata: { latencyMs: 0, source: 'file', freshness: '2026-03-29' },
      },
      {
        signalId: 'dvp',
        score: 0.5,
        weight: 0.08,
        available: false,
        rawData: {},
        metadata: { latencyMs: 0, source: 'db', freshness: '2026-03-29' },
      },
    ]);

    expect(composite).toBe(0.6);
  });

  it('still blends quantitative support when it exists', () => {
    const strategy = new NbaStrategy();

    const composite = strategy.computeComposite([
      {
        signalId: 'grok',
        score: 0.6,
        weight: 0.3,
        available: true,
        rawData: {},
        metadata: { latencyMs: 0, source: 'api', freshness: '2026-03-29T00:00:00.000Z' },
      },
      {
        signalId: 'piff',
        score: 0.82,
        weight: 0.3,
        available: true,
        rawData: {},
        metadata: { latencyMs: 0, source: 'file', freshness: '2026-03-29' },
      },
      {
        signalId: 'rag',
        score: 0.509,
        weight: 0.07,
        available: true,
        rawData: {},
        metadata: { latencyMs: 0, source: 'api', freshness: '2026-03-29T00:00:00.000Z' },
      },
    ]);

    expect(composite).toBeGreaterThan(0.6);
  });
});
