@@ -2878,5 +2878,126 @@ describe('interact (mini)', () => {
28782878 } ) ;
28792879 } ) ;
28802880 } ) ;
2881+
2882+ describe ( 'configuration defaults' , ( ) => {
2883+ describe ( 'scroll animation range defaults' , ( ) => {
2884+ it ( 'should use default range values when rangeStart and rangeEnd are not provided' , ( ) => {
2885+ const scrubEffect : ScrubEffect = {
2886+ namedEffect : { type : 'FadeScroll' , range : 'in' , opacity : 0 } as NamedEffect ,
2887+ } ;
2888+
2889+ const result = effectToAnimationOptions ( scrubEffect ) as { startOffset : any ; endOffset : any } ;
2890+
2891+ expect ( result . startOffset ) . toEqual ( {
2892+ name : 'cover' ,
2893+ offset : { value : 0 , type : 'percentage' } ,
2894+ } ) ;
2895+ expect ( result . endOffset ) . toEqual ( {
2896+ name : 'cover' ,
2897+ offset : { value : 100 , type : 'percentage' } ,
2898+ } ) ;
2899+ } ) ;
2900+
2901+ it ( 'should use provided rangeStart and rangeEnd values when supplied' , ( ) => {
2902+ const scrubEffect : ScrubEffect = {
2903+ namedEffect : { type : 'FadeScroll' , range : 'in' , opacity : 0 } as NamedEffect ,
2904+ rangeStart : { name : 'contain' , offset : { value : 10 , type : 'percentage' } } ,
2905+ rangeEnd : { name : 'entry' , offset : { value : 90 , type : 'percentage' } } ,
2906+ } ;
2907+
2908+ const result = effectToAnimationOptions ( scrubEffect ) as { startOffset : any ; endOffset : any } ;
2909+
2910+ expect ( result . startOffset ) . toEqual ( {
2911+ name : 'contain' ,
2912+ offset : { value : 10 , type : 'percentage' } ,
2913+ } ) ;
2914+ expect ( result . endOffset ) . toEqual ( {
2915+ name : 'entry' ,
2916+ offset : { value : 90 , type : 'percentage' } ,
2917+ } ) ;
2918+ } ) ;
2919+
2920+ it ( 'should use rangeStart.name for endOffset.name when only rangeStart is provided' , ( ) => {
2921+ const scrubEffect : ScrubEffect = {
2922+ namedEffect : { type : 'FadeScroll' , range : 'in' , opacity : 0 } as NamedEffect ,
2923+ rangeStart : { name : 'entry' , offset : { value : 25 , type : 'percentage' } } ,
2924+ } ;
2925+
2926+ const result = effectToAnimationOptions ( scrubEffect ) as { startOffset : any ; endOffset : any } ;
2927+
2928+ expect ( result . startOffset ) . toEqual ( {
2929+ name : 'entry' ,
2930+ offset : { value : 25 , type : 'percentage' } ,
2931+ } ) ;
2932+ expect ( result . endOffset ) . toEqual ( {
2933+ name : 'entry' ,
2934+ offset : { value : 100 , type : 'percentage' } ,
2935+ } ) ;
2936+ } ) ;
2937+
2938+ it ( 'should use default offset when only rangeStart.name is provided' , ( ) => {
2939+ const scrubEffect : ScrubEffect = {
2940+ namedEffect : { type : 'FadeScroll' , range : 'in' , opacity : 0 } as NamedEffect ,
2941+ rangeStart : { name : 'exit' } ,
2942+ } ;
2943+
2944+ const result = effectToAnimationOptions ( scrubEffect ) as { startOffset : any ; endOffset : any } ;
2945+
2946+ expect ( result . startOffset ) . toEqual ( {
2947+ name : 'exit' ,
2948+ offset : { value : 0 , type : 'percentage' } ,
2949+ } ) ;
2950+ expect ( result . endOffset ) . toEqual ( {
2951+ name : 'exit' ,
2952+ offset : { value : 100 , type : 'percentage' } ,
2953+ } ) ;
2954+ } ) ;
2955+
2956+ it ( 'should use default startOffset.name when only rangeEnd is provided' , ( ) => {
2957+ const scrubEffect : ScrubEffect = {
2958+ namedEffect : { type : 'FadeScroll' , range : 'in' , opacity : 0 } as NamedEffect ,
2959+ rangeEnd : { name : 'exit' , offset : { value : 75 , type : 'percentage' } } ,
2960+ } ;
2961+
2962+ const result = effectToAnimationOptions ( scrubEffect ) as { startOffset : any ; endOffset : any } ;
2963+
2964+ expect ( result . startOffset ) . toEqual ( {
2965+ name : 'cover' ,
2966+ offset : { value : 0 , type : 'percentage' } ,
2967+ } ) ;
2968+ expect ( result . endOffset ) . toEqual ( {
2969+ name : 'exit' ,
2970+ offset : { value : 75 , type : 'percentage' } ,
2971+ } ) ;
2972+ } ) ;
2973+ } ) ;
2974+
2975+ it ( 'should assign effectId as keyframeEffect.name when keyframeEffect has no name' , ( ) => {
2976+ const timeEffect = {
2977+ keyframeEffect : {
2978+ keyframes : [ { opacity : '0' } , { opacity : '1' } ] ,
2979+ } ,
2980+ duration : 500 ,
2981+ effectId : 'my-effect-id' ,
2982+ } ;
2983+
2984+ const result = effectToAnimationOptions ( timeEffect as any ) as { keyframeEffect ?: { name ?: string } } ;
2985+
2986+ expect ( result . keyframeEffect ?. name ) . toBe ( 'my-effect-id' ) ;
2987+ } ) ;
2988+
2989+ it ( 'should handle keyframeEffect without name and without effectId' , ( ) => {
2990+ const timeEffect = {
2991+ keyframeEffect : {
2992+ keyframes : [ { opacity : '0' } , { opacity : '1' } ] ,
2993+ } ,
2994+ duration : 500 ,
2995+ } ;
2996+
2997+ const result = effectToAnimationOptions ( timeEffect as any ) as { keyframeEffect ?: { name ?: string } } ;
2998+
2999+ expect ( result . keyframeEffect ?. name ) . toBeUndefined ( ) ;
3000+ } ) ;
3001+ } ) ;
28813002} ) ;
28823003
0 commit comments