Files
pwap/mobile/src/__mocks__/contexts/BiometricAuthContext.tsx
T
pezkuwichain 56af709e8d Add comprehensive test infrastructure and Dark Mode tests
- Created test folder structure (__tests__, __mocks__)
- Added mock contexts (Theme, BiometricAuth, Auth)
- Added mock AsyncStorage
- Implemented 11 passing Dark Mode tests:
  * Rendering tests (3 tests)
  * Toggle functionality tests (2 tests)
  * Persistence tests (2 tests)
  * Theme application tests (2 tests)
  * Edge case tests (2 tests)
- Added testID props to SettingsScreen components
- All tests passing (11/11)

Test Coverage:
- Dark Mode toggle on/off
- AsyncStorage persistence
- Theme color application
- Rapid toggle handling
- Multiple toggle calls
2026-01-14 16:09:23 +03:00

39 lines
1.3 KiB
TypeScript

import React, { createContext, useContext, ReactNode } from 'react';
// Mock Biometric Auth Context for testing
interface BiometricAuthContextType {
isBiometricSupported: boolean;
isBiometricEnrolled: boolean;
isBiometricAvailable: boolean;
biometricType: 'fingerprint' | 'facial' | 'iris' | 'none';
isBiometricEnabled: boolean;
authenticate: () => Promise<boolean>;
enableBiometric: () => Promise<boolean>;
disableBiometric: () => Promise<void>;
}
const mockBiometricContext: BiometricAuthContextType = {
isBiometricSupported: true,
isBiometricEnrolled: true,
isBiometricAvailable: true,
biometricType: 'fingerprint',
isBiometricEnabled: false,
authenticate: jest.fn().mockResolvedValue(true),
enableBiometric: jest.fn().mockResolvedValue(true),
disableBiometric: jest.fn().mockResolvedValue(undefined),
};
const BiometricAuthContext = createContext<BiometricAuthContextType>(mockBiometricContext);
export const MockBiometricAuthProvider: React.FC<{
children: ReactNode;
value?: Partial<BiometricAuthContextType>
}> = ({ children, value = {} }) => {
const contextValue = { ...mockBiometricContext, ...value };
return <BiometricAuthContext.Provider value={contextValue}>{children}</BiometricAuthContext.Provider>;
};
export const useBiometricAuth = () => useContext(BiometricAuthContext);
export default BiometricAuthContext;