mirror of
https://github.com/pezkuwichain/pwap.git
synced 2026-04-28 16:37:56 +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,43 @@
|
||||
import React, { createContext, useContext, ReactNode } from 'react';
|
||||
|
||||
// Mock colors instead of importing from shared
|
||||
const LightColors = {
|
||||
background: '#F5F5F5',
|
||||
surface: '#FFFFFF',
|
||||
text: '#000000',
|
||||
textSecondary: '#666666',
|
||||
border: '#E0E0E0',
|
||||
};
|
||||
|
||||
// Mock Theme Context for testing
|
||||
interface ThemeContextType {
|
||||
isDarkMode: boolean;
|
||||
toggleDarkMode: () => Promise<void>;
|
||||
colors: typeof LightColors;
|
||||
fontSize: 'small' | 'medium' | 'large';
|
||||
setFontSize: (size: 'small' | 'medium' | 'large') => Promise<void>;
|
||||
fontScale: number;
|
||||
}
|
||||
|
||||
const mockThemeContext: ThemeContextType = {
|
||||
isDarkMode: false,
|
||||
toggleDarkMode: jest.fn().mockResolvedValue(undefined),
|
||||
colors: LightColors,
|
||||
fontSize: 'medium',
|
||||
setFontSize: jest.fn().mockResolvedValue(undefined),
|
||||
fontScale: 1,
|
||||
};
|
||||
|
||||
const ThemeContext = createContext<ThemeContextType>(mockThemeContext);
|
||||
|
||||
export const MockThemeProvider: React.FC<{ children: ReactNode; value?: Partial<ThemeContextType> }> = ({
|
||||
children,
|
||||
value = {}
|
||||
}) => {
|
||||
const contextValue = { ...mockThemeContext, ...value };
|
||||
return <ThemeContext.Provider value={contextValue}>{children}</ThemeContext.Provider>;
|
||||
};
|
||||
|
||||
export const useTheme = () => useContext(ThemeContext);
|
||||
|
||||
export default ThemeContext;
|
||||
Reference in New Issue
Block a user