import { describe, it, expect } from 'vitest';
import { SerenityCalculator } from '@domain/services/SerenityCalculator';

describe('SerenityCalculator', () => {
  const calc = new SerenityCalculator();

  it('null target → not done, 0 seconds', () => {
    const r = calc.computeEta({ currentSerenite: 0, target: null, activeGauges: [], gaugeLevels: {} });
    expect(r.done).toBe(false);
    expect(r.seconds).toBe(0);
  });

  it('target already reached → done', () => {
    const r = calc.computeEta({ currentSerenite: -5000, target: -5000, activeGauges: ['baffeur'], gaugeLevels: { baffeur: 50000 } });
    expect(r.done).toBe(true);
  });

  it('needs baffeur to decrease serenite', () => {
    const r = calc.computeEta({ currentSerenite: 0, target: -5000, activeGauges: [], gaugeLevels: {} });
    expect(r.needsGauge).toBe('baffeur');
    expect(r.seconds).toBe(Infinity);
  });

  it('needs caresseur to increase serenite', () => {
    const r = calc.computeEta({ currentSerenite: 0, target: 40, activeGauges: [], gaugeLevels: {} });
    expect(r.needsGauge).toBe('caresseur');
  });

  it('computes time with baffeur active', () => {
    const r = calc.computeEta({ currentSerenite: 0, target: -100, activeGauges: ['baffeur'], gaugeLevels: { baffeur: 50000 } });
    expect(r.done).toBe(false);
    expect(r.seconds).toBeGreaterThan(0);
    expect(r.seconds).toBeLessThan(Infinity);
  });

  it('computes time with caresseur active', () => {
    const r = calc.computeEta({ currentSerenite: 0, target: 100, activeGauges: ['caresseur'], gaugeLevels: { caresseur: 50000 } });
    expect(r.done).toBe(false);
    expect(r.seconds).toBeGreaterThan(0);
    expect(r.seconds).toBeLessThan(Infinity);
  });
});
