mirror of
https://github.com/bergside/typeui.git
synced 2026-09-19 07:24:37 +08:00
46 lines
1.7 KiB
TypeScript
46 lines
1.7 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { parseManagedDesignSystem, parseSkillMetadata } from "../src/generation/existingDesignSystem";
|
|
import { createManagedSkillBody, createManagedSkillFile } from "../src/renderers/shared";
|
|
import { DesignSystemInput } from "../src/types";
|
|
|
|
const sampleDesign: DesignSystemInput = {
|
|
productName: "typeui.sh",
|
|
brandSummary: "Developer-first UI guidance.",
|
|
visualStyle: "modern and clean",
|
|
typographyScale: "12/14/16/20/24/32",
|
|
colorPalette: "primary, neutral, semantic",
|
|
spacingScale: "4/8/12/16/24/32",
|
|
accessibilityRequirements: "WCAG 2.2 AA",
|
|
writingTone: "clear and direct",
|
|
doRules: ["use semantic tokens", "preserve hierarchy"],
|
|
dontRules: ["use low contrast", "break spacing rhythm"]
|
|
};
|
|
|
|
describe("parseManagedDesignSystem", () => {
|
|
it("parses managed content generated by renderer", () => {
|
|
const content = createManagedSkillBody("Cursor", sampleDesign);
|
|
expect(parseManagedDesignSystem(content)).toEqual(sampleDesign);
|
|
});
|
|
|
|
it("returns null when managed block is missing", () => {
|
|
expect(parseManagedDesignSystem("# Manual only")).toBeNull();
|
|
});
|
|
});
|
|
|
|
describe("parseSkillMetadata", () => {
|
|
it("parses frontmatter metadata from generated content", () => {
|
|
const content = createManagedSkillFile("Cursor", sampleDesign, {
|
|
name: "typeui-cli",
|
|
description: "Guide for generating design-system skill files."
|
|
});
|
|
expect(parseSkillMetadata(content)).toEqual({
|
|
name: "typeui-cli",
|
|
description: "Guide for generating design-system skill files."
|
|
});
|
|
});
|
|
|
|
it("returns null when frontmatter is missing", () => {
|
|
expect(parseSkillMetadata(createManagedSkillBody("Cursor", sampleDesign))).toBeNull();
|
|
});
|
|
});
|