|
| 1 | +import { describe, it, expect, vi, beforeEach } from 'vitest'; |
| 2 | +import { render } from '@testing-library/react'; |
| 3 | +import React from 'react'; |
| 4 | +import Template from './template'; |
| 5 | + |
| 6 | +// Mock framer-motion to easily inspect the boundary properties passed to the wrapper |
| 7 | +vi.mock('framer-motion', () => ({ |
| 8 | + motion: { |
| 9 | + div: ({ |
| 10 | + children, |
| 11 | + 'data-testid': testId, |
| 12 | + ...props |
| 13 | + }: { |
| 14 | + children?: React.ReactNode; |
| 15 | + 'data-testid'?: string; |
| 16 | + [key: string]: unknown; |
| 17 | + }) => ( |
| 18 | + <div data-testid={testId || 'motion-div'} data-motion-props={JSON.stringify(props)}> |
| 19 | + {children} |
| 20 | + </div> |
| 21 | + ), |
| 22 | + }, |
| 23 | +})); |
| 24 | + |
| 25 | +describe('AppTemplate - Timezone Boundaries Equivalent (Animation Boundaries)', () => { |
| 26 | + beforeEach(() => { |
| 27 | + vi.clearAllMocks(); |
| 28 | + }); |
| 29 | + |
| 30 | + const getMotionProps = (container: HTMLElement) => { |
| 31 | + const motionDiv = container.querySelector('[data-testid="motion-div"]'); |
| 32 | + if (!motionDiv) throw new Error('Motion div not found'); |
| 33 | + const propsStr = motionDiv.getAttribute('data-motion-props'); |
| 34 | + return propsStr ? JSON.parse(propsStr) : {}; |
| 35 | + }; |
| 36 | + |
| 37 | + it('Transition Boundaries (Daylight Savings Equivalent): strictly defines transition durations without temporal gaps', () => { |
| 38 | + const { container } = render( |
| 39 | + <Template> |
| 40 | + <span /> |
| 41 | + </Template> |
| 42 | + ); |
| 43 | + const props = getMotionProps(container); |
| 44 | + |
| 45 | + expect(props.transition).toBeDefined(); |
| 46 | + expect(props.transition.duration).toBe(0.3); |
| 47 | + expect(props.transition.ease).toBe('easeInOut'); |
| 48 | + }); |
| 49 | + |
| 50 | + it('Initial State Normalization (Leap Year Gaps Equivalent): applies entry offset boundaries accurately', () => { |
| 51 | + const { container } = render( |
| 52 | + <Template> |
| 53 | + <span /> |
| 54 | + </Template> |
| 55 | + ); |
| 56 | + const props = getMotionProps(container); |
| 57 | + |
| 58 | + expect(props.initial).toBeDefined(); |
| 59 | + expect(props.initial.opacity).toBe(0); |
| 60 | + expect(props.initial.y).toBe(8); |
| 61 | + }); |
| 62 | + |
| 63 | + it('Active State Alignment (Visual Dates Equivalent): aligns active frame to absolute baseline coordinates', () => { |
| 64 | + const { container } = render( |
| 65 | + <Template> |
| 66 | + <span /> |
| 67 | + </Template> |
| 68 | + ); |
| 69 | + const props = getMotionProps(container); |
| 70 | + |
| 71 | + expect(props.animate).toBeDefined(); |
| 72 | + expect(props.animate.opacity).toBe(1); |
| 73 | + expect(props.animate.y).toBe(0); |
| 74 | + }); |
| 75 | + |
| 76 | + it('Exit State Offsets (Time Offsets Equivalent): forces exact negative spatial displacement upon exit', () => { |
| 77 | + const { container } = render( |
| 78 | + <Template> |
| 79 | + <span /> |
| 80 | + </Template> |
| 81 | + ); |
| 82 | + const props = getMotionProps(container); |
| 83 | + |
| 84 | + expect(props.exit).toBeDefined(); |
| 85 | + expect(props.exit.opacity).toBe(0); |
| 86 | + expect(props.exit.y).toBe(-8); |
| 87 | + }); |
| 88 | + |
| 89 | + it('Child Node Preservation (Grid Data Integrity Equivalent): ensures content seamlessly passes through boundary wrappers', () => { |
| 90 | + const { getByTestId } = render( |
| 91 | + <Template> |
| 92 | + <div data-testid="preserved-child">Hello Boundary</div> |
| 93 | + </Template> |
| 94 | + ); |
| 95 | + |
| 96 | + const child = getByTestId('preserved-child'); |
| 97 | + expect(child).toBeTruthy(); |
| 98 | + expect(child.textContent).toBe('Hello Boundary'); |
| 99 | + }); |
| 100 | +}); |
0 commit comments