import { describe, expect, it } from "vitest";
import {
  BODY_STYLE_DEFAULTS,
  normalizeBodyStyle,
  physiqueFor,
  physiqueFromBodyStyle,
} from "./bodyStyle.js";

describe("bodyStyle", () => {
  it("normalizes missing / packed values", () => {
    expect(normalizeBodyStyle(null)).toEqual(BODY_STYLE_DEFAULTS);
    expect(normalizeBodyStyle({ m: 0.5, u: -0.25, f: 0.1 })).toEqual({
      mass: 0.5,
      muscle: -0.25,
      fat: 0.1,
    });
    expect(normalizeBodyStyle({ mass: 2, muscle: -3, fat: -1 })).toEqual({
      mass: 1,
      muscle: -1,
      fat: 0,
    });
  });

  it("maps extremes to bulkier / leaner physiques", () => {
    const lean = physiqueFromBodyStyle({ mass: -1, muscle: 0, fat: 0 });
    const heavy = physiqueFromBodyStyle({ mass: 1, muscle: 1, fat: 1 });
    expect(heavy.bulk).toBeGreaterThan(lean.bulk);
    expect(heavy.shoulderF).toBeGreaterThan(lean.shoulderF);
    expect(heavy.waistF).toBeGreaterThan(lean.waistF);
  });

  it("stacks sex base under slider multipliers", () => {
    const male = physiqueFor("male", { mass: 0, muscle: 0, fat: 0 });
    const female = physiqueFor("female", { mass: 0, muscle: 0, fat: 0 });
    expect(male.bulk).toBeGreaterThan(female.bulk);
    expect(male.shoulderF).toBeGreaterThan(female.shoulderF);
  });
});
