Feat: uncut gems fixed

This commit is contained in:
kvan7
2025-08-02 10:54:31 -05:00
parent 988c943372
commit 3a64e003f6
11 changed files with 575 additions and 66 deletions

View File

@@ -1,28 +1,42 @@
// itemTextToSections.test.ts
import { __testExports } from "@/parser/Parser";
import { describe, expect, test } from "vitest";
import { beforeEach, describe, expect, test } from "vitest";
import { setupTests } from "../vitest.setup";
import {
MagicItem,
NormalItem,
RareItem,
RareWithImplicit,
UniqueItem,
} from "./items";
import { loadForLang } from "@/assets/data";
describe("itemTextToSections", () => {
setupTests();
beforeEach(async () => {
setupTests();
await loadForLang("en");
});
test("empty string should not throw", () => {
expect(() => __testExports.itemTextToSections("")).not.toThrow();
});
test("standard item", () => {
const sections = __testExports.itemTextToSections(
`Item Class: Staves
Rarity: Magic
Chiming Staff of Havoc
--------
Requirements:
Level: 58
Int: 133 (unmet)
--------
Item Level: 62
--------
+5 to Level of all Chaos Spell Skills
`,
);
expect(sections.length).toBe(4);
const sections = __testExports.itemTextToSections(RareItem.rawText);
expect(sections.length).toBe(RareItem.sectionCount);
});
test("magic item", () => {
const sections = __testExports.itemTextToSections(MagicItem.rawText);
expect(sections.length).toBe(MagicItem.sectionCount);
});
test("normal item", () => {
const sections = __testExports.itemTextToSections(NormalItem.rawText);
expect(sections.length).toBe(NormalItem.sectionCount);
});
test("unique item", () => {
const sections = __testExports.itemTextToSections(UniqueItem.rawText);
expect(sections.length).toBe(UniqueItem.sectionCount);
});
test("rare item with implicit", () => {
const sections = __testExports.itemTextToSections(RareWithImplicit.rawText);
expect(sections.length).toBe(RareWithImplicit.sectionCount);
});
});