From 92b6283920a6f7da7a50ac262ad1a1d26cd5248c Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Wed, 1 Apr 2026 20:15:31 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=AA=20[testing=20improvement]=20Add=20?= =?UTF-8?q?test=20for=20fadeInDelayed?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/mobile/__tests__/animations.test.ts | 20 +++++++++++++++++++- apps/mobile/jest.setup.js | 12 ++++++++++-- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/apps/mobile/__tests__/animations.test.ts b/apps/mobile/__tests__/animations.test.ts index d4f56e8..fc27d0e 100644 --- a/apps/mobile/__tests__/animations.test.ts +++ b/apps/mobile/__tests__/animations.test.ts @@ -1,6 +1,11 @@ -import { SpringPresets, TimingPresets } from '../src/utils/animations'; +import { withDelay, withTiming } from 'react-native-reanimated'; +import { SpringPresets, TimingPresets, fadeInDelayed } from '../src/utils/animations'; describe('Animation Presets', () => { + beforeEach(() => { + jest.clearAllMocks(); + }); + test('SpringPresets should have correct configurations', () => { expect(SpringPresets.snappy).toEqual({ damping: 18, stiffness: 200, mass: 0.8 }); expect(SpringPresets.bouncy).toEqual({ damping: 10, stiffness: 120, mass: 1 }); @@ -17,4 +22,17 @@ describe('Animation Presets', () => { expect(TimingPresets.normal.easing).toBeDefined(); expect(TimingPresets.slow.easing).toBeDefined(); }); + + describe('fadeInDelayed', () => { + test('should call withDelay and withTiming with correct parameters', () => { + const targetValue = 1; + const delayMs = 300; + + fadeInDelayed(targetValue, delayMs); + + expect(withTiming).toHaveBeenCalledWith(targetValue, TimingPresets.normal); + // withTiming mock returns the value itself, so withDelay gets the targetValue as second arg + expect(withDelay).toHaveBeenCalledWith(delayMs, targetValue); + }); + }); }); diff --git a/apps/mobile/jest.setup.js b/apps/mobile/jest.setup.js index f6fd815..e67f21a 100644 --- a/apps/mobile/jest.setup.js +++ b/apps/mobile/jest.setup.js @@ -6,8 +6,16 @@ jest.mock('react-native-reanimated', () => { return { useSharedValue: jest.fn(() => ({ value: 0 })), useAnimatedStyle: jest.fn(() => ({})), - withSpring: jest.fn((val) => val), - withTiming: jest.fn((val) => val), + withSpring: jest.fn((val, config) => val), + withTiming: jest.fn((val, config) => val), + withDelay: jest.fn((delay, val) => val), + withSequence: jest.fn((...args) => args), + Easing: { + out: jest.fn((val) => val), + inOut: jest.fn((val) => val), + quad: 'quad', + cubic: 'cubic', + }, createAnimatedComponent: jest.fn((Component) => Component), default: { View: 'View',