feat(sprint1-step3): PrestigePanel + MilestoneBar + équilibrage générateurs fixes

This commit is contained in:
2026-03-17 07:09:14 +01:00
parent c69da320cc
commit 9f0ccda99b
3 changed files with 151 additions and 0 deletions

View File

@@ -11,6 +11,50 @@ import {
DEFAULT_GENERATORS,
} from "../core/economy";
// PrestigePanel visibility guard — canPrestige drives render condition
// Ces tests valident l'invariant : le panneau prestige ne doit jamais être
// visible (canPrestige = false) si les ressources sont inférieures au seuil.
describe("PrestigePanel visibility (canPrestige guard)", () => {
it("canPrestige = false pour resources = 0 → panneau non visible", () => {
expect(canPrestige({ ...DEFAULT_STATE, resources: 0 })).toBe(false);
});
it("canPrestige = false pour resources = 999 999 → panneau non visible", () => {
expect(canPrestige({ ...DEFAULT_STATE, resources: 999_999 })).toBe(false);
});
it("canPrestige = true pour resources = 1 000 000 → panneau visible", () => {
expect(canPrestige({ ...DEFAULT_STATE, resources: 1_000_000 })).toBe(true);
});
});
describe("applyPrestige — post-prestige state", () => {
const prestigeState = {
...DEFAULT_STATE,
resources: 1_500_000,
generators: DEFAULT_STATE.generators.map((g) => ({ ...g, owned: 3 })),
prestigeCount: 0,
prestigeMultiplier: 1,
};
it("ressources = 0 après prestige", () => {
expect(applyPrestige(prestigeState).resources).toBe(0);
});
it("multiplicateur = 1.1 après premier prestige", () => {
expect(applyPrestige(prestigeState).prestigeMultiplier).toBeCloseTo(1.1);
});
it("tous les générateurs owned = 0 après prestige", () => {
const result = applyPrestige(prestigeState);
expect(result.generators.every((g) => g.owned === 0)).toBe(true);
});
it("prestigeCount incrémenté à 1 après premier prestige", () => {
expect(applyPrestige(prestigeState).prestigeCount).toBe(1);
});
});
describe("generatorCost", () => {
it("retourne baseCost quand owned = 0", () => {
const gen = { ...DEFAULT_GENERATORS[0], owned: 0 };