import { describe, expect, it } from "vitest"; import { convertFigurePart, convertFigureString, getNewFormatFigure, } from "./figure-convert"; describe("convertFigurePart", () => { it("converts head part", () => { expect(convertFigurePart("hr-11782-40-40")).toBe("hd-180-1"); expect(convertFigurePart("hr-11782-41-41")).toBe("hd-180-2"); }); it("converts hair part", () => { expect(convertFigurePart("hd-180-7-14")).toBe("hd-180-1"); expect(convertFigurePart("hd-180-8-14")).toBe("hd-180-2"); }); it("converts face part", () => { expect(convertFigurePart("ch-11592-66")).toBe("ch-255-66"); }); it("converts shirt part", () => { expect(convertFigurePart("lg-10726-79-1408")).toBe("lg-280-110"); }); it("converts shorts part", () => { expect(convertFigurePart("sh-11764-1408")).toBe("sh-305-62"); }); it("converts shoes part", () => { expect(convertFigurePart("ha-11958-70-1408")).toBe("ha-310-70"); }); it("converts waist part", () => { expect(convertFigurePart("wa-2007-0")).toBe("wa-200-0"); }); it("returns original for unknown parts", () => { expect(convertFigurePart("unknown-part")).toBe("unknown-part"); expect(convertFigurePart("hd-999-99")).toBe("hd-999-99"); }); }); describe("convertFigureString", () => { it("converts full figure string from old to new format", () => { const oldFigure = "hr-11782-40-40.hd-180-7-14.ch-11592-66.lg-10726-79-1408.sh-11764-1408.ha-11958-70-1408.wa-2007-0"; const newFigure = "hd-180-1.hd-180-1.ch-255-66.lg-280-110.sh-305-62.ha-310-70.wa-200-0"; expect(convertFigureString(oldFigure)).toBe(newFigure); }); it("handles empty string", () => { expect(convertFigureString("")).toBe(""); }); it("handles already converted figure", () => { const newFigure = "hd-180-1.ch-255-66.lg-280-110"; expect(convertFigureString(newFigure)).toBe(newFigure); }); }); describe("getNewFormatFigure", () => { it("converts figure using getNewFormatFigure", () => { const oldFigure = "hr-11782-40-40.hd-180-7-14.ch-11592-66"; expect(getNewFormatFigure(oldFigure)).toBe("hd-180-1.hd-180-1.ch-255-66"); }); });