feat: filter figure parts (exclude shoes, waist, dedupe head)

- Default convertFigureString now excludes shoes (ha-), waist (wa-), and duplicate head
- Added ConvertFigureOptions to customize filtering
- Updated tests to reflect new defaults
This commit is contained in:
openhands committed 2026-08-09 19:50:24 +02:00
1 parent 7a2c0fd4d4
commit 2f708bcf11
2 files changed
+68 -8

No files matched your search

+24 -4
View File
@@ -43,12 +43,25 @@ describe("convertFigurePart", () => {
});
describe("convertFigureString", () => {
it("converts full figure string from old to new format", () => {
it("converts full figure string from old to new format (with defaults: exclude shoes, waist, dedupe head)", () => {
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.ch-255-66.lg-280-110.sh-305-62";
expect(convertFigureString(oldFigure)).toBe(newFigure);
});
it("includes all parts when options disabled", () => {
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);
expect(
convertFigureString(oldFigure, {
excludeShoes: false,
excludeWaist: false,
dedupeHead: false,
}),
).toBe(newFigure);
});
it("handles empty string", () => {
@@ -62,8 +75,15 @@ describe("convertFigureString", () => {
});
describe("getNewFormatFigure", () => {
it("converts figure using getNewFormatFigure", () => {
it("converts figure using getNewFormatFigure with defaults", () => {
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");
expect(getNewFormatFigure(oldFigure)).toBe("hd-180-1.ch-255-66");
});
it("allows custom options", () => {
const oldFigure = "hr-11782-40-40.hd-180-7-14.ch-11592-66.ha-11958-70-1408";
expect(getNewFormatFigure(oldFigure, { excludeShoes: false })).toBe(
"hd-180-1.ch-255-66.ha-310-70",
);
});
});