mirror of
https://github.com/pezkuwichain/pwap.git
synced 2026-04-26 01:47:58 +00:00
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:
@@ -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;
|
||||
Reference in New Issue
Block a user