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
This commit is contained in:
2026-01-14 16:09:23 +03:00
parent 51dcd1f507
commit 58964d7813
6 changed files with 398 additions and 1 deletions
@@ -0,0 +1,38 @@
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;