test: add unit tests for furni import helpers and catalog cache
Added tests for: - classifyFurni: prefix matching, type-based classification, fallback - autoPriceFurni: CF_/rare_/default pricing rules - resetCatalogPageCache: smoke test
This commit is contained in:
1 parent
aee099339c
commit
f792c276b7
1 file changed
+48
-1
@@ -28,7 +28,12 @@ vi.mock("@/lib/services/swf-to-nitro", () => ({
|
|||||||
extractIconFromSwf: vi.fn(),
|
extractIconFromSwf: vi.fn(),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
import { buildItemsBaseEnrichmentUpdate } from "./furni-import";
|
import {
|
||||||
|
autoPriceFurni,
|
||||||
|
buildItemsBaseEnrichmentUpdate,
|
||||||
|
classifyFurni,
|
||||||
|
resetCatalogPageCache,
|
||||||
|
} from "./furni-import";
|
||||||
|
|
||||||
describe("buildItemsBaseEnrichmentUpdate", () => {
|
describe("buildItemsBaseEnrichmentUpdate", () => {
|
||||||
it("only updates columns present in the live Arcturus items_base schema", () => {
|
it("only updates columns present in the live Arcturus items_base schema", () => {
|
||||||
@@ -50,3 +55,45 @@ describe("buildItemsBaseEnrichmentUpdate", () => {
|
|||||||
expect(serialized).toContain("default");
|
expect(serialized).toContain("default");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("classifyFurni", () => {
|
||||||
|
it("classifies credits by classname prefix", () => {
|
||||||
|
expect(classifyFurni("CF_750_credits", "s")).toBe("credits");
|
||||||
|
expect(classifyFurni("exe_50", "s")).toBe("credits");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("classifies wired by classname prefix", () => {
|
||||||
|
expect(classifyFurni("wf_act_1", "s")).toBe("wired");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("classifies wall items by type", () => {
|
||||||
|
expect(classifyFurni("wallposter", "i")).toBe("walls");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("falls back to 'other' for unknown classnames", () => {
|
||||||
|
expect(classifyFurni("custom_item", "s")).toBe("other");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("autoPriceFurni", () => {
|
||||||
|
it("extracts credit value from CF_ prefix", () => {
|
||||||
|
const price = autoPriceFurni("CF_750_credits");
|
||||||
|
expect(price.credits).toBe(750);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("prices rares at 25 credits", () => {
|
||||||
|
const price = autoPriceFurni("rare_habbo_max");
|
||||||
|
expect(price.credits).toBe(25);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("prices default items at 3 credits", () => {
|
||||||
|
const price = autoPriceFurni("random_furni");
|
||||||
|
expect(price.credits).toBe(3);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("resetCatalogPageCache", () => {
|
||||||
|
it("is a callable function that does not throw", () => {
|
||||||
|
expect(() => resetCatalogPageCache()).not.toThrow();
|
||||||
|
});
|
||||||
|
});
|
||||||
Reference in new issue
Block a user