68 lines
2.8 KiB
TypeScript
68 lines
2.8 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { getCharacterGenerationStrategy, buildPoseConstraints } from "./servicesConfig";
|
|
|
|
describe("servicesConfig", () => {
|
|
describe("getCharacterGenerationStrategy", () => {
|
|
it("returns standard strategy when modelType is none", () => {
|
|
const result = getCharacterGenerationStrategy("none", "Goku", null);
|
|
expect(result.strategy).toBe("standard");
|
|
expect(result.promptPrefix).toContain("Goku");
|
|
expect(result.referenceImages).toHaveLength(0);
|
|
});
|
|
|
|
it("returns lora strategy with LoRA prefix", () => {
|
|
const result = getCharacterGenerationStrategy("lora", "Goldorak", "https://example.com/ref.png");
|
|
expect(result.strategy).toBe("lora");
|
|
expect(result.promptPrefix).toContain("[LoRA:Goldorak]");
|
|
expect(result.referenceImages).toHaveLength(1);
|
|
expect(result.referenceImages[0].url).toBe("https://example.com/ref.png");
|
|
});
|
|
|
|
it("returns ip_adapter strategy with reference image", () => {
|
|
const result = getCharacterGenerationStrategy("ip_adapter", "Albator", "https://example.com/sheet.png");
|
|
expect(result.strategy).toBe("ip_adapter");
|
|
expect(result.promptPrefix).toContain("Albator");
|
|
expect(result.promptPrefix).toContain("reference image");
|
|
expect(result.referenceImages).toHaveLength(1);
|
|
});
|
|
|
|
it("returns empty reference images when no sheet URL", () => {
|
|
const result = getCharacterGenerationStrategy("lora", "Test", undefined);
|
|
expect(result.referenceImages).toHaveLength(0);
|
|
});
|
|
});
|
|
|
|
describe("buildPoseConstraints", () => {
|
|
it("adds pose preservation constraints to prompt", () => {
|
|
const result = buildPoseConstraints("Draw a warrior", {
|
|
preservePose: true,
|
|
preserveProportions: true,
|
|
preservePosition: true,
|
|
});
|
|
expect(result).toContain("Draw a warrior");
|
|
expect(result).toContain("exact same body pose");
|
|
expect(result).toContain("identical proportions");
|
|
expect(result).toContain("exact same coordinates");
|
|
expect(result).toContain("animation frame consistency");
|
|
});
|
|
|
|
it("skips constraints when disabled", () => {
|
|
const result = buildPoseConstraints("Simple prompt", {
|
|
preservePose: false,
|
|
preserveProportions: false,
|
|
preservePosition: false,
|
|
});
|
|
expect(result).toContain("Simple prompt");
|
|
expect(result).not.toContain("exact same body pose");
|
|
expect(result).not.toContain("identical proportions");
|
|
expect(result).toContain("animation frame consistency");
|
|
});
|
|
|
|
it("includes pose description when provided", () => {
|
|
const result = buildPoseConstraints("Redraw character", {
|
|
poseDescription: "Standing with arms raised, facing right",
|
|
});
|
|
expect(result).toContain("Standing with arms raised, facing right");
|
|
});
|
|
});
|
|
});
|