/** * @format */ import React from 'react'; import { NativeModules } from 'react-native'; import ReactTestRenderer from 'react-test-renderer'; const emptySnapshot = { phase: 'idle', isCapturing: false, isMonitoring: false, startedAt: 0, statusMessage: 'Captura parada.', connectedDevice: null, discoveredDevices: [], samples: [], sessions: [], services: [], characteristics: [], batteryOptimizationIgnored: true, }; NativeModules.FightRateCapture = { addListener: jest.fn(), removeListeners: jest.fn(), getSnapshot: jest.fn(async () => emptySnapshot), startMonitoring: jest.fn(async () => emptySnapshot), startCapture: jest.fn(async () => emptySnapshot), startWorkout: jest.fn(async () => ({ ...emptySnapshot, isMonitoring: true, isCapturing: true, })), connectToDevice: jest.fn(async () => emptySnapshot), stopCapture: jest.fn(async () => emptySnapshot), stopWorkout: jest.fn(async () => ({ ...emptySnapshot, isMonitoring: true, })), stopMonitoring: jest.fn(async () => emptySnapshot), getSessionSamples: jest.fn(async () => []), getContinuousSamples: jest.fn(async () => []), isIgnoringBatteryOptimizations: jest.fn(async () => true), openBatteryOptimizationSettings: jest.fn(async () => true), }; // react-native-gesture-handler requires a native module; mock it for tests. NativeModules.RNGestureHandlerModule = { attachGestureHandler: jest.fn(), createGestureHandler: jest.fn(), dropGestureHandler: jest.fn(), updateGestureHandler: jest.fn(), flushOperations: jest.fn(), install: jest.fn(), State: { UNDETERMINED: 0, FAILED: 1, BEGAN: 2, CANCELLED: 3, ACTIVE: 4, END: 5 }, Directions: { RIGHT: 1, LEFT: 2, UP: 4, DOWN: 8 }, }; const App = require('../App').default; test('renders correctly', async () => { await ReactTestRenderer.act(() => { ReactTestRenderer.create(); }); });