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
@@ -0,0 +1,42 @@
// Mock AsyncStorage for testing
const storage: { [key: string]: string } = {};
export default {
setItem: jest.fn((key: string, value: string) => {
storage[key] = value;
return Promise.resolve();
}),
getItem: jest.fn((key: string) => {
return Promise.resolve(storage[key] || null);
}),
removeItem: jest.fn((key: string) => {
delete storage[key];
return Promise.resolve();
}),
clear: jest.fn(() => {
Object.keys(storage).forEach(key => delete storage[key]);
return Promise.resolve();
}),
getAllKeys: jest.fn(() => {
return Promise.resolve(Object.keys(storage));
}),
multiGet: jest.fn((keys: string[]) => {
return Promise.resolve(
keys.map(key => [key, storage[key] || null])
);
}),
multiSet: jest.fn((keyValuePairs: [string, string][]) => {
keyValuePairs.forEach(([key, value]) => {
storage[key] = value;
});
return Promise.resolve();
}),
multiRemove: jest.fn((keys: string[]) => {
keys.forEach(key => delete storage[key]);
return Promise.resolve();
}),
_clear: () => {
Object.keys(storage).forEach(key => delete storage[key]);
},
_getStorage: () => storage,
};