import { describe, expect, it } from 'vitest';
import { levelFromXp, progressInLevel, totalXpForLevel, xpForNextLevel } from './phase3.js';

describe('phase3 xp helpers', () => {
  it('computes xp for next level', () => {
    expect(xpForNextLevel(0)).toBe(100);
    expect(xpForNextLevel(1)).toBe(155);
  });

  it('derives level from xp', () => {
    expect(levelFromXp(0)).toBe(0);
    expect(levelFromXp(100)).toBe(1);
    expect(levelFromXp(totalXpForLevel(5))).toBe(5);
  });

  it('reports progress in current level', () => {
    const progress = progressInLevel(totalXpForLevel(2) + 10);
    expect(progress.level).toBe(2);
    expect(progress.intoLevel).toBe(10);
    expect(progress.needed).toBe(xpForNextLevel(2));
  });
});
