Файли
openidea/src/platform/motion.test.ts
T
l0ng-ai baa0171d8a feat(appearance): add a Reduce motion setting (#5940)
Adds Reduce motion under Appearance > Accessibility. When on, or when the system asks for reduced motion, CSS animations and transitions finish at once; script-driven motion reads the same preference.

Fixes #5887
2026-11-26 01:42:42 +08:00

24 рядки
742 B
TypeScript

import { afterEach, describe, expect, it, vi } from "vitest";
import { reducedMotion } from "./motion";
describe("reducedMotion", () => {
afterEach(() => {
delete document.documentElement.dataset.reduceMotion;
vi.unstubAllGlobals();
});
const media = (matches: boolean) =>
vi.stubGlobal("matchMedia", (query: string) => ({ matches: matches && query.includes("reduce") }));
it("follows the Reduce motion setting", () => {
media(false);
expect(reducedMotion()).toBe(false);
document.documentElement.dataset.reduceMotion = "";
expect(reducedMotion()).toBe(true);
});
it("follows the system preference when the setting is off", () => {
media(true);
expect(reducedMotion()).toBe(true);
});
});