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 9f27c345e6
commit 56af709e8d
6 changed files with 398 additions and 1 deletions
+5 -1
View File
@@ -111,12 +111,14 @@ const SettingsScreen: React.FC = () => {
subtitle,
value,
onToggle,
testID,
}: {
icon: string;
title: string;
subtitle?: string;
value: boolean;
onToggle: (value: boolean) => void;
testID?: string;
}) => (
<View style={styles.settingItem}>
<View style={styles.settingIcon}>
@@ -127,6 +129,7 @@ const SettingsScreen: React.FC = () => {
{subtitle && <Text style={styles.settingSubtitle}>{subtitle}</Text>}
</View>
<Switch
testID={testID}
value={value}
onValueChange={onToggle}
trackColor={{ false: '#E0E0E0', true: KurdistanColors.kesk }}
@@ -136,7 +139,7 @@ const SettingsScreen: React.FC = () => {
);
return (
<SafeAreaView style={styles.container}>
<SafeAreaView style={styles.container} testID="settings-screen">
<StatusBar barStyle={isDarkMode ? "light-content" : "dark-content"} />
{/* Header */}
@@ -161,6 +164,7 @@ const SettingsScreen: React.FC = () => {
onToggle={async () => {
await toggleDarkMode();
}}
testID="dark-mode-switch"
/>
<SettingItem