packages/react-components/react-motion-components-preview/library/src/testing/README.md
This directory contains comprehensive testing utilities for FluentUI motion components and atoms.
The testing utilities are organized into two main categories:
testUtils.ts)Utilities for testing presence motion components:
expectPresenceMotionObject() - Validates motion objects with enter/exit statesexpectPresenceMotionArray() - Validates motion arrays for complex animationsexpectPresenceMotionFunction() - Validates motion function structuremockAnimation() - Mock Animation object for testingatomTestUtils.ts)Specialized utilities for testing motion atoms:
expectValidAtomMotion() - Validates basic atom motion structureexpectReversedKeyframes() - Ensures enter/exit atoms have properly reversed keyframesexpectConsistentTiming() - Validates timing properties across multiple atomsexpectCustomParameters() - Validates custom timing parametersexpectKeyframeProperty() - Validates specific CSS properties in keyframesNote: Atom-specific validators like expectFadeAtom(), expectScaleAtom(), and expectSlideAtom() are defined within their respective test files to maintain better organization and reduce coupling.
import { expectPresenceMotionObject } from '../testing';
import { Fade } from './Fade';
it('creates valid presence motion', () => {
const component = createPresenceComponent(createFadePresence());
expectPresenceMotionObject(component);
});
import { expectValidAtomMotion } from '../testing';
import { fadeAtom } from './fade-atom';
// Atom-specific validators are defined within each test file
function expectFadeAtom(atom, direction, fromOpacity = 0, toOpacity = 1) {
// Implementation specific to fade atom testing
}
it('creates valid fade atom', () => {
const atom = fadeAtom({ direction: 'enter', duration: 300 });
expectValidAtomMotion(atom);
expectFadeAtom(atom, 'enter');
});
import { expectCustomParameters } from '../testing';
it('applies custom timing', () => {
const atom = fadeAtom({
direction: 'enter',
duration: 500,
delay: 100,
easing: 'ease-out',
});
expectCustomParameters(atom, {
duration: 500,
delay: 100,
easing: 'ease-out',
});
});
import { expectReversedKeyframes } from '../testing';
it('has properly reversed enter/exit keyframes', () => {
const enterAtom = scaleAtom({ direction: 'enter', duration: 300 });
const exitAtom = scaleAtom({ direction: 'exit', duration: 300 });
expectReversedKeyframes(enterAtom, exitAtom);
});
testing/
├── index.ts # Exports all testing utilities
├── testUtils.ts # Component-level testing utilities
├── atomTestUtils.ts # Atom-level testing utilities
└── README.md # This documentation
When adding new motion atoms or components:
atomTestUtils.tsindex.tsCurrent test coverage includes: