@@ -68,6 +68,27 @@ vi.mock('../src/library/scroll', () => ({
6868 ] ) ,
6969 getNames : vi . fn ( ( ) => [ 'fade-scroll' ] ) ,
7070 } ,
71+ ParallaxScroll : vi . fn ( ( options : AnimationOptions ) => [
72+ {
73+ fill : 'both' ,
74+ easing : 'linear' ,
75+ startOffsetAdd : '-25vh' ,
76+ endOffsetAdd : '25vh' ,
77+ startOffset : {
78+ name : 'entry' ,
79+ offset : { value : 0 , type : 'percentage' } ,
80+ } ,
81+ endOffset : {
82+ name : 'exit' ,
83+ offset : { value : 100 , type : 'percentage' } ,
84+ } ,
85+ keyframes : [
86+ { transform : 'translateY(-25vh)' } ,
87+ { transform : 'translateY(25vh)' } ,
88+ ] ,
89+ ...options ,
90+ } ,
91+ ] ) ,
7192 } ,
7293} ) ) ;
7394
@@ -121,7 +142,33 @@ vi.mock('../src/library/entrance', () => ({
121142} ) ) ;
122143
123144vi . mock ( '../src/library/ongoing' , ( ) => ( {
124- ongoingAnimations : { } ,
145+ ongoingAnimations : {
146+ Poke : {
147+ style : vi . fn ( ( options : AnimationOptions ) => [
148+ {
149+ name : 'motion-poke' ,
150+ easing : 'linear' ,
151+ keyframes : [
152+ { translate : '0 0' } ,
153+ { translate : '10px 0' } ,
154+ ] ,
155+ ...options ,
156+ } ,
157+ ] ) ,
158+ web : vi . fn ( ( options : AnimationOptions ) => [
159+ {
160+ name : 'motion-poke' ,
161+ easing : 'linear' ,
162+ keyframes : [
163+ { translate : '0 0' } ,
164+ { translate : '10px 0' } ,
165+ ] ,
166+ ...options ,
167+ } ,
168+ ] ) ,
169+ getNames : vi . fn ( ( ) => [ 'motion-poke' ] ) ,
170+ } ,
171+ } ,
125172} ) ) ;
126173
127174vi . mock ( '../src/library/mouse' , ( ) => ( {
@@ -2306,28 +2353,17 @@ describe('motion.ts', () => {
23062353 ( AnimationGroup as Mock ) . mockRestore ( ) ;
23072354 } ) ;
23082355
2309- test ( 'should return an empty animation if reducedMotion is true and iterations is NOT 1' , async ( ) => {
2356+ test ( 'should return null if reducedMotion is true and iterations is NOT 1' , async ( ) => {
23102357 const animationOptions : AnimationOptions = {
23112358 namedEffect : { type : 'Poke' , id : 'poke' , direction : 'right' } ,
23122359 duration : 1000 ,
23132360 iterations : Infinity ,
23142361 } ;
23152362
2316- // Mock AnimationGroup constructor
2317- const { AnimationGroup } = await import ( '../src/AnimationGroup' ) ;
2318- ( AnimationGroup as Mock ) . mockImplementation ( function ( animations : any ) {
2319- mockAnimationGroup . animations = animations ;
2320- return mockAnimationGroup ;
2321- } ) ;
2363+ const result = getAnimation ( mockElement , animationOptions , undefined , true ) ;
23222364
2323- getAnimation ( mockElement , animationOptions , undefined , true ) ;
2324-
2325- expect ( AnimationGroup ) . toHaveBeenCalledWith (
2326- [ ] ,
2327- expect . objectContaining ( animationOptions ) ,
2328- ) ;
2329-
2330- ( AnimationGroup as Mock ) . mockRestore ( ) ;
2365+ // When reducedMotion is true and iterations !== 1, no animation should be created
2366+ expect ( result ) . toBeNull ( ) ;
23312367 } ) ;
23322368
23332369 test ( 'should return a Web Animation if *NO* CSS animation is found' , async ( ) => {
0 commit comments