Files
WRNexusJS/packages/ui/test/ui.test.ts
T
2026-07-19 17:25:37 +05:30

71 lines
2.4 KiB
TypeScript

import { expect, test } from "bun:test";
import { readFileSync } from "node:fs";
import { join } from "node:path";
import { compileWireFile } from "../../compiler/src/index.ts";
import { uiComponentNames, uiComponentsDir, uiCss } from "../src/index.ts";
test("bundled UI assets are discoverable and readable", () => {
expect(uiComponentNames()).toContain("Button");
expect(uiComponentNames()).toContain("FAQAccordion");
expect(uiComponentNames()).toContain("AnnouncementBar");
expect(uiComponentNames()).toContain("BackToTop");
expect(readFileSync(join(uiComponentsDir(), "Button.wrn"), "utf8")).toContain("component Button");
expect(uiCss()).toContain("--wire-");
});
test("PDF minimum-release and essential build-first components are bundled", () => {
const required = [
"Typography",
"Form",
"FormLabel",
"FormHelpText",
"FormError",
"LoadingButton",
"Combobox",
"MultiSelect",
"TimePicker",
"DateTimePicker",
"RecurringSchedulePicker",
"QuietHoursPicker",
"ConfirmationDialog",
"DataTable",
"FilterBar",
"MegaMenu",
"DesktopNavigation",
"ProductsMegaMenu",
"MobileNavigation",
"MarketingPageShell",
"ProductPageShell",
"LegalPageShell",
"ProductCard",
"MetricGrid",
"FAQ",
"PricingComparisonTable",
"SDKTabs",
"LegalTableOfContents",
"CookiePreferencesDialog",
];
expect(uiComponentNames()).toEqual(expect.arrayContaining(required));
});
test("component-system CSS includes responsive, theme-token, focus, and reduced-motion rules", () => {
const css = uiCss();
expect(css).toContain("@media (max-width: 768px)");
expect(css).toContain("@media (max-width: 480px)");
expect(css).toContain("@media (prefers-reduced-motion: reduce)");
expect(css).toContain(":focus-visible");
expect(css).toContain("var(--wire-color-surface)");
expect(css).toContain("min-height: 44px");
expect(css).toContain("--wire-motion-base");
expect(css).toContain("--wire-ease-emphasized");
expect(css).toContain("@keyframes wire-component-enter");
expect(css).toContain("@keyframes wire-dialog-enter");
expect(css).toContain("@media (hover: hover) and (pointer: fine)");
});
test.each(uiComponentNames())("bundled UI component %s compiles", (name) => {
const path = join(uiComponentsDir(), `${name}.wrn`);
expect(() => compileWireFile(readFileSync(path, "utf8"), path)).not.toThrow();
});