28 lines
2.0 KiB
TypeScript
28 lines
2.0 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { calculateFinalStats, formatFinalStat } from "./final-stats";
|
|
import type { Build, CatalogBaseStat } from "./types";
|
|
|
|
const build: Build = {
|
|
id: "test", characterId: "10000032", characterKey: "bennett", characterName: "Bennett", characterImageUrl: "", level: 90, maxLevel: 90, constellation: 0, talents: [9, 9, 9], weaponId: "11401", weaponKey: "favoniussword", weaponName: "Favonius Sword", weaponLevel: 90, weaponMaxLevel: 90, refinement: 1, artifactMode: "4pc", artifactOneId: "15007", artifactOneKey: "noblesseoblige", artifactOneName: "Noblesse Oblige", artifactTwoId: "", artifactTwoKey: "", artifactTwoName: "", sands: "er", goblet: "pyro%", circlet: "cr", rolls: { hp: 2, atk: 1, def: 0, em: 2, er: 3, "hp%": 0, "atk%": 4, "def%": 1, cr: 5, cd: 6 },
|
|
};
|
|
const character: CatalogBaseStat[] = [{ key: "hp", value: 12397 }, { key: "atk", value: 191 }, { key: "def", value: 771 }, { key: "ER", value: "26.7" }];
|
|
const weapon: CatalogBaseStat[] = [{ key: "atk", value: 454 }, { key: "Energy Recharge%", value: 61.3 }];
|
|
|
|
describe("final character stats", () => {
|
|
it("combines raw level 90 character, weapon, and artifact stats", () => {
|
|
const stats = calculateFinalStats(build, character, weapon);
|
|
expect(stats.find((stat) => stat.key === "HP")?.value).toBeCloseTo(17684.88);
|
|
expect(stats.find((stat) => stat.key === "ATK")?.value).toBeCloseTo(1100.508);
|
|
expect(stats.find((stat) => stat.key === "DEF")?.value).toBeCloseTo(818.802);
|
|
expect(stats.find((stat) => stat.key === "ER")?.value).toBeCloseTo(2.5633);
|
|
expect(stats.find((stat) => stat.key === "CR")?.value).toBeCloseTo(0.5265);
|
|
expect(stats.find((stat) => stat.key === "CD")?.value).toBeCloseTo(0.8972);
|
|
expect(stats.find((stat) => stat.key === "pyro")?.value).toBeCloseTo(0.466);
|
|
});
|
|
|
|
it("formats final flat and percentage values", () => {
|
|
expect(formatFinalStat({ key: "HP", value: 17684.88 })).toBe("HP 17,685");
|
|
expect(formatFinalStat({ key: "ER", value: 2.6503, percent: true })).toBe("ER 265.03%");
|
|
});
|
|
});
|