Files
EpicNext-Cms/src/lib/services/furni-attachment.test.ts
T
Simo 2619bec165
CI / check (push) Successful in 1m30s
CI / deploy (push) Successful in 1m26s
CI / e2e (push) Successful in 25s
feat(catalog): queue furniture imports with history and matching file attachments
2026-09-05 17:02:26 +02:00

34 lines
1.1 KiB
TypeScript

import { expect, it } from "vitest";
import { validateFurnitureAttachment } from "./furni-attachment";
import { createNitroBundle, encodePng } from "./swf/nitro-builder";
const png = encodePng(1, 1, Buffer.from([1, 2, 3, 255]));
it("accepts the matching bundle including color variants sharing a library", () => {
const buffer = createNitroBundle({ name: "chair" }, png, "chair");
expect(validateFurnitureAttachment(buffer, "chair*2")).toBe(buffer);
});
it("rejects a similarly named furniture bundle", () => {
expect(() =>
validateFurnitureAttachment(
createNitroBundle({ name: "china_light" }, png, "china_light"),
"nft_china_light",
),
).toThrow("does not belong");
});
it("rejects a renamed JSON entry with mismatching metadata", () => {
expect(() =>
validateFurnitureAttachment(
createNitroBundle({ name: "china_light" }, png, "nft_china_light"),
"nft_china_light",
),
).toThrow("does not belong");
});
it("rejects missing texture data", () => {
expect(() =>
validateFurnitureAttachment(
createNitroBundle({ name: "chair" }, Buffer.from("not png"), "chair"),
"chair",
),
).toThrow("not a PNG");
});