refactor(motion): simplify to default and reduced
This commit is contained in:
@@ -1,52 +1,35 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import {
|
||||
defaultMotionAccessibility,
|
||||
defaultMotionMode,
|
||||
defaultMotionPack,
|
||||
motionAccessibilityDetails,
|
||||
motionAccessibilityNames,
|
||||
motionModeNames,
|
||||
motionPackDetails,
|
||||
motionPackNames,
|
||||
setMotionAccessibility,
|
||||
setMotionMode,
|
||||
setMotionPack
|
||||
motionModeDetails,
|
||||
setMotionMode
|
||||
} from "@ai-ui/tokens";
|
||||
|
||||
describe("motion contract", () => {
|
||||
it("exposes default values that exist in the public name sets", () => {
|
||||
expect(motionPackNames).toContain(defaultMotionPack);
|
||||
expect(motionAccessibilityNames).toContain(defaultMotionAccessibility);
|
||||
expect(motionModeNames).toContain(defaultMotionMode);
|
||||
expect(motionPackDetails[defaultMotionPack].label).toBeTruthy();
|
||||
expect(motionAccessibilityDetails[defaultMotionAccessibility].label).toBeTruthy();
|
||||
expect(motionModeDetails[defaultMotionMode].label).toBeTruthy();
|
||||
});
|
||||
|
||||
it("sets the active motion pack on the document root", () => {
|
||||
setMotionPack("spring");
|
||||
it("sets default motion mode on the document root", () => {
|
||||
setMotionMode("default");
|
||||
|
||||
expect(document.documentElement.dataset.motionPack).toBe("spring");
|
||||
expect(document.documentElement.dataset.motion).toBe("default");
|
||||
});
|
||||
|
||||
it("sets reduced motion accessibility on the document root", () => {
|
||||
setMotionAccessibility("reduced");
|
||||
it("sets reduced motion mode on the document root", () => {
|
||||
setMotionMode("reduced");
|
||||
|
||||
expect(document.documentElement.dataset.motion).toBe("reduced");
|
||||
});
|
||||
|
||||
it("removes the accessibility override when system mode is restored", () => {
|
||||
setMotionAccessibility("reduced");
|
||||
setMotionMode("system");
|
||||
|
||||
expect(document.documentElement.dataset.motion).toBeUndefined();
|
||||
});
|
||||
|
||||
it("supports explicit full motion override on custom roots", () => {
|
||||
it("supports explicit reduced mode on custom roots", () => {
|
||||
const target = document.createElement("div");
|
||||
|
||||
setMotionAccessibility("full", target);
|
||||
setMotionMode("reduced", target);
|
||||
|
||||
expect(target.dataset.motion).toBe("full");
|
||||
expect(target.dataset.motion).toBe("reduced");
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user