import { readdirSync, readFileSync } from "node:fs"; import { expect, it } from "vitest"; // docs/DESIGN.md (Motion): `prefers-reduced-motion` is respected. A pulse that loops for as long as // something lasts — a running job's dot, a queued download, a skeleton bone — is the motion that rule // is about, and seven of them pulsed regardless. Each is `motion-safe:animate-pulse`, or pairs the // pulse with `motion-reduce:animate-none` on the same line. function sources(): Array<[string, string]> { const walk = (u: URL, prefix: string): Array<[string, string]> => readdirSync(u, { withFileTypes: true }).flatMap((e) => { if (e.isDirectory()) return walk(new URL(`${e.name}/`, u), `${prefix}${e.name}/`); if (!/\.tsx?$/.test(e.name) || e.name.includes(".test.")) return []; return [ [`${prefix}${e.name}`, readFileSync(new URL(e.name, u), "utf-8")] as [string, string], ]; }); return walk(new URL("../", import.meta.url), ""); } it("every looping pulse stops for a reader who asked for less motion", () => { const unguarded = sources().flatMap(([name, src]) => src .split("\n") .map((line, i) => [line, i + 1] as const) .filter( ([line]) => /(? `${name}:${n}`), ); expect(unguarded).toEqual([]); });