rootStartupLoading.test.ts 983 B

123456789101112131415161718192021
  1. import { createElement } from "react";
  2. import { renderToStaticMarkup } from "react-dom/server";
  3. import { describe, expect, it } from "vitest";
  4. import { RootStartupLoading, ZCodeStartupLogoBadge } from "@/root/RootStartupLoading.js";
  5. describe("RootStartupLoading", () => {
  6. it("静态品牌图标不渲染呼吸动画", () => {
  7. const html = renderToStaticMarkup(createElement(ZCodeStartupLogoBadge, { animated: false }));
  8. expect(html).toContain("<svg");
  9. expect(html).not.toContain("<animate");
  10. });
  11. it("启动阻塞态使用整体呼吸的 ZCode SVG 而不是可见 loading 文案", () => {
  12. const html = renderToStaticMarkup(createElement(RootStartupLoading, { label: "加载中..." }));
  13. expect(html).toContain('data-testid="root-startup-loading"');
  14. expect(html).toContain('aria-label="加载中..."');
  15. expect(html).toContain("<svg");
  16. expect(html).toContain('attributeName="opacity"');
  17. expect(html).not.toContain(">加载中...<");
  18. });
  19. });