@umituz/react-native-settings 2.0.0 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +129 -3
- package/lib/__tests__/setup.d.ts +5 -0
- package/lib/__tests__/setup.d.ts.map +1 -0
- package/lib/__tests__/setup.js +143 -0
- package/lib/__tests__/setup.js.map +1 -0
- package/lib/domain/repositories/ISettingsRepository.d.ts +51 -0
- package/lib/domain/repositories/ISettingsRepository.d.ts.map +1 -0
- package/lib/domain/repositories/ISettingsRepository.js +8 -0
- package/lib/domain/repositories/ISettingsRepository.js.map +1 -0
- package/lib/index.d.ts +35 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +32 -0
- package/lib/index.js.map +1 -0
- package/lib/infrastructure/storage/SettingsStore.d.ts +36 -0
- package/lib/infrastructure/storage/SettingsStore.d.ts.map +1 -0
- package/lib/infrastructure/storage/SettingsStore.js +144 -0
- package/lib/infrastructure/storage/SettingsStore.js.map +1 -0
- package/lib/presentation/components/CloudSyncSetting.d.ts +16 -0
- package/lib/presentation/components/CloudSyncSetting.d.ts.map +1 -0
- package/lib/presentation/components/CloudSyncSetting.js +30 -0
- package/lib/presentation/components/CloudSyncSetting.js.map +1 -0
- package/lib/presentation/components/DisclaimerCard.d.ts +15 -0
- package/lib/presentation/components/DisclaimerCard.d.ts.map +1 -0
- package/lib/presentation/components/DisclaimerCard.js +73 -0
- package/lib/presentation/components/DisclaimerCard.js.map +1 -0
- package/lib/presentation/components/DisclaimerModal.d.ts +13 -0
- package/lib/presentation/components/DisclaimerModal.d.ts.map +1 -0
- package/lib/presentation/components/DisclaimerModal.js +62 -0
- package/lib/presentation/components/DisclaimerModal.js.map +1 -0
- package/lib/presentation/components/DisclaimerSetting.d.ts +39 -0
- package/lib/presentation/components/DisclaimerSetting.d.ts.map +1 -0
- package/lib/presentation/components/DisclaimerSetting.js +59 -0
- package/lib/presentation/components/DisclaimerSetting.js.map +1 -0
- package/lib/presentation/components/SettingItem.d.ts +45 -0
- package/lib/presentation/components/SettingItem.d.ts.map +1 -0
- package/lib/presentation/components/SettingItem.js +113 -0
- package/lib/presentation/components/SettingItem.js.map +1 -0
- package/lib/presentation/components/SettingsErrorBoundary.d.ts +23 -0
- package/lib/presentation/components/SettingsErrorBoundary.d.ts.map +1 -0
- package/lib/presentation/components/SettingsErrorBoundary.js +73 -0
- package/lib/presentation/components/SettingsErrorBoundary.js.map +1 -0
- package/lib/presentation/components/SettingsFooter.d.ts +11 -0
- package/lib/presentation/components/SettingsFooter.d.ts.map +1 -0
- package/lib/presentation/components/SettingsFooter.js +31 -0
- package/lib/presentation/components/SettingsFooter.js.map +1 -0
- package/lib/presentation/components/SettingsSection.d.ts +13 -0
- package/lib/presentation/components/SettingsSection.d.ts.map +1 -0
- package/lib/presentation/components/SettingsSection.js +37 -0
- package/lib/presentation/components/SettingsSection.js.map +1 -0
- package/lib/presentation/components/StorageClearSetting.d.ts +16 -0
- package/lib/presentation/components/StorageClearSetting.d.ts.map +1 -0
- package/lib/presentation/components/StorageClearSetting.js +21 -0
- package/lib/presentation/components/StorageClearSetting.js.map +1 -0
- package/lib/presentation/components/UserProfileHeader.d.ts +30 -0
- package/lib/presentation/components/UserProfileHeader.d.ts.map +1 -0
- package/lib/presentation/components/UserProfileHeader.js +119 -0
- package/lib/presentation/components/UserProfileHeader.js.map +1 -0
- package/lib/presentation/screens/AppearanceScreen.d.ts +8 -0
- package/lib/presentation/screens/AppearanceScreen.d.ts.map +1 -0
- package/lib/presentation/screens/AppearanceScreen.js +8 -0
- package/lib/presentation/screens/AppearanceScreen.js.map +1 -0
- package/lib/presentation/screens/SettingsScreen.d.ts +38 -0
- package/lib/presentation/screens/SettingsScreen.d.ts.map +1 -0
- package/lib/presentation/screens/SettingsScreen.js +37 -0
- package/lib/presentation/screens/SettingsScreen.js.map +1 -0
- package/lib/presentation/screens/components/AboutLegalSection.d.ts +15 -0
- package/lib/presentation/screens/components/AboutLegalSection.d.ts.map +1 -0
- package/lib/presentation/screens/components/AboutLegalSection.js +28 -0
- package/lib/presentation/screens/components/AboutLegalSection.js.map +1 -0
- package/lib/presentation/screens/components/AppearanceSection.d.ts +12 -0
- package/lib/presentation/screens/components/AppearanceSection.d.ts.map +1 -0
- package/lib/presentation/screens/components/AppearanceSection.js +21 -0
- package/lib/presentation/screens/components/AppearanceSection.js.map +1 -0
- package/lib/presentation/screens/components/LanguageSection.d.ts +12 -0
- package/lib/presentation/screens/components/LanguageSection.d.ts.map +1 -0
- package/lib/presentation/screens/components/LanguageSection.js +26 -0
- package/lib/presentation/screens/components/LanguageSection.js.map +1 -0
- package/lib/presentation/screens/components/NotificationsSection.d.ts +12 -0
- package/lib/presentation/screens/components/NotificationsSection.d.ts.map +1 -0
- package/lib/presentation/screens/components/NotificationsSection.js +58 -0
- package/lib/presentation/screens/components/NotificationsSection.js.map +1 -0
- package/lib/presentation/screens/components/SettingsContent.d.ts +36 -0
- package/lib/presentation/screens/components/SettingsContent.d.ts.map +1 -0
- package/lib/presentation/screens/components/SettingsContent.js +81 -0
- package/lib/presentation/screens/components/SettingsContent.js.map +1 -0
- package/lib/presentation/screens/components/SettingsHeader.d.ts +12 -0
- package/lib/presentation/screens/components/SettingsHeader.d.ts.map +1 -0
- package/lib/presentation/screens/components/SettingsHeader.js +59 -0
- package/lib/presentation/screens/components/SettingsHeader.js.map +1 -0
- package/lib/presentation/screens/components/index.d.ts +9 -0
- package/lib/presentation/screens/components/index.d.ts.map +1 -0
- package/lib/presentation/screens/components/index.js +9 -0
- package/lib/presentation/screens/components/index.js.map +1 -0
- package/lib/presentation/screens/hooks/useFeatureDetection.d.ts +21 -0
- package/lib/presentation/screens/hooks/useFeatureDetection.d.ts.map +1 -0
- package/lib/presentation/screens/hooks/useFeatureDetection.js +82 -0
- package/lib/presentation/screens/hooks/useFeatureDetection.js.map +1 -0
- package/lib/presentation/screens/types/CustomSection.d.ts +19 -0
- package/lib/presentation/screens/types/CustomSection.d.ts.map +1 -0
- package/lib/presentation/screens/types/CustomSection.js +6 -0
- package/lib/presentation/screens/types/CustomSection.js.map +1 -0
- package/lib/presentation/screens/types/ExtendedConfig.d.ts +68 -0
- package/lib/presentation/screens/types/ExtendedConfig.d.ts.map +1 -0
- package/lib/presentation/screens/types/ExtendedConfig.js +6 -0
- package/lib/presentation/screens/types/ExtendedConfig.js.map +1 -0
- package/lib/presentation/screens/types/FeatureConfig.d.ts +95 -0
- package/lib/presentation/screens/types/FeatureConfig.d.ts.map +1 -0
- package/lib/presentation/screens/types/FeatureConfig.js +6 -0
- package/lib/presentation/screens/types/FeatureConfig.js.map +1 -0
- package/lib/presentation/screens/types/SettingsConfig.d.ts +97 -0
- package/lib/presentation/screens/types/SettingsConfig.d.ts.map +1 -0
- package/lib/presentation/screens/types/SettingsConfig.js +6 -0
- package/lib/presentation/screens/types/SettingsConfig.js.map +1 -0
- package/lib/presentation/screens/types/index.d.ts +10 -0
- package/lib/presentation/screens/types/index.d.ts.map +1 -0
- package/lib/presentation/screens/types/index.js +6 -0
- package/lib/presentation/screens/types/index.js.map +1 -0
- package/lib/presentation/screens/utils/normalizeConfig.d.ts +44 -0
- package/lib/presentation/screens/utils/normalizeConfig.d.ts.map +1 -0
- package/lib/presentation/screens/utils/normalizeConfig.js +38 -0
- package/lib/presentation/screens/utils/normalizeConfig.js.map +1 -0
- package/package.json +46 -11
- package/src/__tests__/integration.test.tsx +371 -0
- package/src/__tests__/performance.test.tsx +369 -0
- package/src/__tests__/setup.test.tsx +20 -0
- package/src/__tests__/setup.ts +157 -0
- package/src/index.ts +9 -0
- package/src/infrastructure/storage/SettingsStore.ts +90 -45
- package/src/infrastructure/storage/__tests__/SettingsStore.test.tsx +302 -0
- package/src/presentation/components/CloudSyncSetting.tsx +11 -17
- package/src/presentation/components/DisclaimerCard.tsx +115 -0
- package/src/presentation/components/DisclaimerModal.tsx +104 -0
- package/src/presentation/components/DisclaimerSetting.tsx +77 -159
- package/src/presentation/components/SettingItem.tsx +11 -2
- package/src/presentation/components/SettingsErrorBoundary.tsx +126 -0
- package/src/presentation/components/StorageClearSetting.tsx +13 -8
- package/src/presentation/components/UserProfileHeader.tsx +48 -11
- package/src/presentation/components/__tests__/CloudSyncSetting.test.tsx +78 -0
- package/src/presentation/components/__tests__/DisclaimerCard.test.tsx +208 -0
- package/src/presentation/components/__tests__/DisclaimerModal.test.tsx +236 -0
- package/src/presentation/components/__tests__/DisclaimerSetting.test.tsx +74 -0
- package/src/presentation/components/__tests__/SettingItem.test.tsx +189 -0
- package/src/presentation/components/__tests__/SettingsErrorBoundary.test.tsx +186 -0
- package/src/presentation/screens/SettingsScreen.tsx +29 -159
- package/src/presentation/screens/__tests__/SettingsScreen.test.tsx +322 -0
- package/src/presentation/screens/components/AboutLegalSection.tsx +14 -5
- package/src/presentation/screens/components/AppearanceSection.tsx +1 -1
- package/src/presentation/screens/components/LanguageSection.tsx +2 -1
- package/src/presentation/screens/components/NotificationsSection.tsx +19 -14
- package/src/presentation/screens/components/SettingsContent.tsx +167 -0
- package/src/presentation/screens/components/SettingsHeader.tsx +79 -0
- package/src/presentation/screens/hooks/__tests__/useFeatureDetection.test.tsx +261 -0
- package/src/presentation/screens/hooks/useFeatureDetection.ts +15 -5
- package/src/presentation/screens/types/CustomSection.ts +20 -0
- package/src/presentation/screens/types/ExtendedConfig.ts +68 -0
- package/src/presentation/screens/types/FeatureConfig.ts +102 -0
- package/src/presentation/screens/types/SettingsConfig.ts +116 -0
- package/src/presentation/screens/types/index.ts +20 -0
- package/src/presentation/screens/utils/normalizeConfig.ts +2 -1
- package/src/presentation/screens/types.ts +0 -263
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tests for CloudSyncSetting Component
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import { render, fireEvent } from '@testing-library/react-native';
|
|
7
|
+
import { CloudSyncSetting } from '../CloudSyncSetting';
|
|
8
|
+
|
|
9
|
+
// Mock lucide-react-native
|
|
10
|
+
jest.mock('lucide-react-native', () => ({
|
|
11
|
+
Cloud: 'Cloud',
|
|
12
|
+
}));
|
|
13
|
+
|
|
14
|
+
// Mock SettingItem component
|
|
15
|
+
jest.mock('../SettingItem', () => {
|
|
16
|
+
const React = require('react');
|
|
17
|
+
const { View, Text } = require('react-native');
|
|
18
|
+
|
|
19
|
+
return {
|
|
20
|
+
SettingItem: ({ icon, title, value, onPress, testID, showSwitch, switchValue, onSwitchChange, disabled, isLast }: any) => (
|
|
21
|
+
React.createElement(View, {
|
|
22
|
+
testID: testID || 'setting-item',
|
|
23
|
+
onTouchEnd: onPress,
|
|
24
|
+
style: { padding: 16 }
|
|
25
|
+
}, [
|
|
26
|
+
React.createElement(Text, { key: 'title' }, title || ''),
|
|
27
|
+
value && React.createElement(Text, { key: 'value' }, value),
|
|
28
|
+
showSwitch && React.createElement(Text, { key: 'switch' }, switchValue ? 'ON' : 'OFF'),
|
|
29
|
+
])
|
|
30
|
+
),
|
|
31
|
+
};
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
describe('CloudSyncSetting', () => {
|
|
35
|
+
it('renders with default props', () => {
|
|
36
|
+
const { getByText } = render(<CloudSyncSetting />);
|
|
37
|
+
|
|
38
|
+
expect(getByText('cloud_sync')).toBeTruthy();
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it('renders with custom title', () => {
|
|
42
|
+
const { getByText } = render(<CloudSyncSetting title="Custom Sync" />);
|
|
43
|
+
|
|
44
|
+
expect(getByText('Custom Sync')).toBeTruthy();
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it('shows syncing state when isSyncing is true', () => {
|
|
48
|
+
const { getByText } = render(<CloudSyncSetting isSyncing={true} />);
|
|
49
|
+
|
|
50
|
+
expect(getByText('syncing')).toBeTruthy();
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
it('displays custom description when provided', () => {
|
|
54
|
+
const { getByText } = render(
|
|
55
|
+
<CloudSyncSetting description="Custom description" />
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
expect(getByText('Custom description')).toBeTruthy();
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it('shows last synced time when provided', () => {
|
|
62
|
+
const lastSynced = new Date(Date.now() - 5 * 60 * 1000); // 5 minutes ago
|
|
63
|
+
const { getByText } = render(<CloudSyncSetting lastSynced={lastSynced} />);
|
|
64
|
+
|
|
65
|
+
expect(getByText('last_synced_5m_ago')).toBeTruthy();
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it('handles onPress callback', () => {
|
|
69
|
+
const mockOnPress = jest.fn();
|
|
70
|
+
const { getByTestId } = render(
|
|
71
|
+
<CloudSyncSetting onPress={mockOnPress} />
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
const pressable = getByTestId('setting-item');
|
|
75
|
+
fireEvent.press(pressable);
|
|
76
|
+
expect(mockOnPress).toHaveBeenCalled();
|
|
77
|
+
});
|
|
78
|
+
});
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tests for DisclaimerCard Component
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import { render, fireEvent } from '@testing-library/react-native';
|
|
7
|
+
import { DisclaimerCard } from '../DisclaimerCard';
|
|
8
|
+
|
|
9
|
+
// Mock dependencies
|
|
10
|
+
jest.mock('@umituz/react-native-design-system-theme', () => ({
|
|
11
|
+
useAppDesignTokens: () => ({
|
|
12
|
+
colors: {
|
|
13
|
+
backgroundPrimary: '#ffffff',
|
|
14
|
+
},
|
|
15
|
+
spacing: {
|
|
16
|
+
md: 16,
|
|
17
|
+
},
|
|
18
|
+
typography: {
|
|
19
|
+
labelLarge: {
|
|
20
|
+
fontWeight: '500',
|
|
21
|
+
fontSize: 14,
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
}),
|
|
25
|
+
withAlpha: jest.fn((color: string, alpha: number) => `${color}${alpha}`),
|
|
26
|
+
}));
|
|
27
|
+
|
|
28
|
+
jest.mock('@umituz/react-native-design-system-atoms', () => ({
|
|
29
|
+
AtomicText: ({ children, type, color, style }: any) => (
|
|
30
|
+
<Text style={style} testID={`atomic-text-${type}-${color}`}>
|
|
31
|
+
{children}
|
|
32
|
+
</Text>
|
|
33
|
+
),
|
|
34
|
+
AtomicIcon: ({ name, color, size, style }: any) => (
|
|
35
|
+
<Text style={style} testID={`atomic-icon-${name}-${color}-${size}`}>
|
|
36
|
+
Icon: {name}
|
|
37
|
+
</Text>
|
|
38
|
+
),
|
|
39
|
+
}));
|
|
40
|
+
|
|
41
|
+
import { Text } from 'react-native';
|
|
42
|
+
|
|
43
|
+
describe('DisclaimerCard', () => {
|
|
44
|
+
it('renders correctly with basic props', () => {
|
|
45
|
+
const { getByTestId, getByText } = render(
|
|
46
|
+
<DisclaimerCard
|
|
47
|
+
title="Test Title"
|
|
48
|
+
shortMessage="Test Message"
|
|
49
|
+
iconName="AlertTriangle"
|
|
50
|
+
iconColor="#FF9800"
|
|
51
|
+
backgroundColor="#FFF3E0"
|
|
52
|
+
onPress={jest.fn()}
|
|
53
|
+
/>
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
expect(getByText('Test Title')).toBeTruthy();
|
|
57
|
+
expect(getByText('Test Message')).toBeTruthy();
|
|
58
|
+
expect(getByTestId('disclaimer-setting')).toBeTruthy();
|
|
59
|
+
expect(getByTestId('atomic-icon-AlertTriangle-warning')).toBeTruthy();
|
|
60
|
+
expect(getByTestId('atomic-icon-ArrowRight-secondary-sm')).toBeTruthy();
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it('calls onPress when pressed', () => {
|
|
64
|
+
const mockOnPress = jest.fn();
|
|
65
|
+
const { getByTestId } = render(
|
|
66
|
+
<DisclaimerCard
|
|
67
|
+
title="Test Title"
|
|
68
|
+
shortMessage="Test Message"
|
|
69
|
+
iconName="AlertTriangle"
|
|
70
|
+
iconColor="#FF9800"
|
|
71
|
+
backgroundColor="#FFF3E0"
|
|
72
|
+
onPress={mockOnPress}
|
|
73
|
+
/>
|
|
74
|
+
);
|
|
75
|
+
|
|
76
|
+
fireEvent.press(getByTestId('disclaimer-setting'));
|
|
77
|
+
expect(mockOnPress).toHaveBeenCalledTimes(1);
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
it('applies correct styling with theme tokens', () => {
|
|
81
|
+
const { getByTestId } = render(
|
|
82
|
+
<DisclaimerCard
|
|
83
|
+
title="Test Title"
|
|
84
|
+
shortMessage="Test Message"
|
|
85
|
+
iconName="AlertTriangle"
|
|
86
|
+
iconColor="#FF9800"
|
|
87
|
+
backgroundColor="#FFF3E0"
|
|
88
|
+
onPress={jest.fn()}
|
|
89
|
+
/>
|
|
90
|
+
);
|
|
91
|
+
|
|
92
|
+
const card = getByTestId('disclaimer-setting');
|
|
93
|
+
expect(card.props.style).toContainEqual({
|
|
94
|
+
backgroundColor: '#FFF3E0',
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
it('renders with different icon names', () => {
|
|
99
|
+
const { getByTestId } = render(
|
|
100
|
+
<DisclaimerCard
|
|
101
|
+
title="Test Title"
|
|
102
|
+
shortMessage="Test Message"
|
|
103
|
+
iconName="Info"
|
|
104
|
+
iconColor="#2196F3"
|
|
105
|
+
backgroundColor="#E3F2FD"
|
|
106
|
+
onPress={jest.fn()}
|
|
107
|
+
/>
|
|
108
|
+
);
|
|
109
|
+
|
|
110
|
+
expect(getByTestId('atomic-icon-Info-warning')).toBeTruthy();
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
it('handles long text content', () => {
|
|
114
|
+
const longTitle = 'This is a very long disclaimer title that should be handled properly';
|
|
115
|
+
const longMessage = 'This is a very long disclaimer message that should wrap properly and not break the layout';
|
|
116
|
+
|
|
117
|
+
const { getByText } = render(
|
|
118
|
+
<DisclaimerCard
|
|
119
|
+
title={longTitle}
|
|
120
|
+
shortMessage={longMessage}
|
|
121
|
+
iconName="AlertTriangle"
|
|
122
|
+
iconColor="#FF9800"
|
|
123
|
+
backgroundColor="#FFF3E0"
|
|
124
|
+
onPress={jest.fn()}
|
|
125
|
+
/>
|
|
126
|
+
);
|
|
127
|
+
|
|
128
|
+
expect(getByText(longTitle)).toBeTruthy();
|
|
129
|
+
expect(getByText(longMessage)).toBeTruthy();
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
it('has correct accessibility properties', () => {
|
|
133
|
+
const mockOnPress = jest.fn();
|
|
134
|
+
const { getByTestId } = render(
|
|
135
|
+
<DisclaimerCard
|
|
136
|
+
title="Test Title"
|
|
137
|
+
shortMessage="Test Message"
|
|
138
|
+
iconName="AlertTriangle"
|
|
139
|
+
iconColor="#FF9800"
|
|
140
|
+
backgroundColor="#FFF3E0"
|
|
141
|
+
onPress={mockOnPress}
|
|
142
|
+
/>
|
|
143
|
+
);
|
|
144
|
+
|
|
145
|
+
const touchable = getByTestId('disclaimer-setting');
|
|
146
|
+
expect(touchable.props.activeOpacity).toBe(0.7);
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
it('uses withAlpha utility correctly', () => {
|
|
150
|
+
const { withAlpha } = require('@umituz/react-native-design-system-theme');
|
|
151
|
+
|
|
152
|
+
render(
|
|
153
|
+
<DisclaimerCard
|
|
154
|
+
title="Test Title"
|
|
155
|
+
shortMessage="Test Message"
|
|
156
|
+
iconName="AlertTriangle"
|
|
157
|
+
iconColor="#FF9800"
|
|
158
|
+
backgroundColor="#FFF3E0"
|
|
159
|
+
onPress={jest.fn()}
|
|
160
|
+
/>
|
|
161
|
+
);
|
|
162
|
+
|
|
163
|
+
expect(withAlpha).toHaveBeenCalledWith('#FF9800', 0.2);
|
|
164
|
+
expect(withAlpha).toHaveBeenCalledWith('#FF9800', 0.4);
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
it('maintains correct layout structure', () => {
|
|
168
|
+
const { getByTestId } = render(
|
|
169
|
+
<DisclaimerCard
|
|
170
|
+
title="Test Title"
|
|
171
|
+
shortMessage="Test Message"
|
|
172
|
+
iconName="AlertTriangle"
|
|
173
|
+
iconColor="#FF9800"
|
|
174
|
+
backgroundColor="#FFF3E0"
|
|
175
|
+
onPress={jest.fn()}
|
|
176
|
+
/>
|
|
177
|
+
);
|
|
178
|
+
|
|
179
|
+
// Check that icon container has correct styles
|
|
180
|
+
expect(getByTestId('atomic-icon-AlertTriangle-warning')).toBeTruthy();
|
|
181
|
+
|
|
182
|
+
// Check that title and arrow are present
|
|
183
|
+
expect(getByTestId('atomic-icon-ArrowRight-secondary-sm')).toBeTruthy();
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
it('handles press events correctly', () => {
|
|
187
|
+
const mockOnPress = jest.fn();
|
|
188
|
+
const { getByTestId } = render(
|
|
189
|
+
<DisclaimerCard
|
|
190
|
+
title="Test Title"
|
|
191
|
+
shortMessage="Test Message"
|
|
192
|
+
iconName="AlertTriangle"
|
|
193
|
+
iconColor="#FF9800"
|
|
194
|
+
backgroundColor="#FFF3E0"
|
|
195
|
+
onPress={mockOnPress}
|
|
196
|
+
/>
|
|
197
|
+
);
|
|
198
|
+
|
|
199
|
+
// Test single press
|
|
200
|
+
fireEvent.press(getByTestId('disclaimer-setting'));
|
|
201
|
+
expect(mockOnPress).toHaveBeenCalledTimes(1);
|
|
202
|
+
|
|
203
|
+
// Test multiple presses
|
|
204
|
+
fireEvent.press(getByTestId('disclaimer-setting'));
|
|
205
|
+
fireEvent.press(getByTestId('disclaimer-setting'));
|
|
206
|
+
expect(mockOnPress).toHaveBeenCalledTimes(3);
|
|
207
|
+
});
|
|
208
|
+
});
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tests for DisclaimerModal Component
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import { render, fireEvent } from '@testing-library/react-native';
|
|
7
|
+
import { DisclaimerModal } from '../DisclaimerModal';
|
|
8
|
+
|
|
9
|
+
// Mock dependencies
|
|
10
|
+
jest.mock('@umituz/react-native-design-system-theme', () => ({
|
|
11
|
+
useAppDesignTokens: () => ({
|
|
12
|
+
colors: {
|
|
13
|
+
backgroundPrimary: '#ffffff',
|
|
14
|
+
borderLight: '#e0e0e0',
|
|
15
|
+
},
|
|
16
|
+
}),
|
|
17
|
+
}));
|
|
18
|
+
|
|
19
|
+
jest.mock('@umituz/react-native-design-system-atoms', () => ({
|
|
20
|
+
AtomicText: ({ children, type, color, style }: any) => (
|
|
21
|
+
<Text style={style} testID={`atomic-text-${type}-${color}`}>
|
|
22
|
+
{children}
|
|
23
|
+
</Text>
|
|
24
|
+
),
|
|
25
|
+
AtomicIcon: ({ name, color, size, style }: any) => (
|
|
26
|
+
<Text style={style} testID={`atomic-icon-${name}-${color}-${size}`}>
|
|
27
|
+
Icon: {name}
|
|
28
|
+
</Text>
|
|
29
|
+
),
|
|
30
|
+
}));
|
|
31
|
+
|
|
32
|
+
import { Text, Modal, ScrollView } from 'react-native';
|
|
33
|
+
|
|
34
|
+
describe('DisclaimerModal', () => {
|
|
35
|
+
it('renders null when visible is false', () => {
|
|
36
|
+
const { queryByTestId } = render(
|
|
37
|
+
<DisclaimerModal
|
|
38
|
+
visible={false}
|
|
39
|
+
title="Test Title"
|
|
40
|
+
content="Test Content"
|
|
41
|
+
onClose={jest.fn()}
|
|
42
|
+
/>
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
expect(queryByTestId('disclaimer-modal')).toBeNull();
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it('renders correctly when visible is true', () => {
|
|
49
|
+
const { getByTestId, getByText } = render(
|
|
50
|
+
<DisclaimerModal
|
|
51
|
+
visible={true}
|
|
52
|
+
title="Test Title"
|
|
53
|
+
content="Test Content"
|
|
54
|
+
onClose={jest.fn()}
|
|
55
|
+
/>
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
expect(getByTestId('disclaimer-modal')).toBeTruthy();
|
|
59
|
+
expect(getByText('Test Title')).toBeTruthy();
|
|
60
|
+
expect(getByText('Test Content')).toBeTruthy();
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it('calls onClose when close button is pressed', () => {
|
|
64
|
+
const mockOnClose = jest.fn();
|
|
65
|
+
const { getByTestId } = render(
|
|
66
|
+
<DisclaimerModal
|
|
67
|
+
visible={true}
|
|
68
|
+
title="Test Title"
|
|
69
|
+
content="Test Content"
|
|
70
|
+
onClose={mockOnClose}
|
|
71
|
+
/>
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
fireEvent.press(getByTestId('close-disclaimer-modal'));
|
|
75
|
+
expect(mockOnClose).toHaveBeenCalledTimes(1);
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
it('applies correct theme colors', () => {
|
|
79
|
+
const { getByTestId } = render(
|
|
80
|
+
<DisclaimerModal
|
|
81
|
+
visible={true}
|
|
82
|
+
title="Test Title"
|
|
83
|
+
content="Test Content"
|
|
84
|
+
onClose={jest.fn()}
|
|
85
|
+
/>
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
const modalContainer = getByTestId('disclaimer-modal');
|
|
89
|
+
expect(modalContainer.props.style).toContainEqual({
|
|
90
|
+
backgroundColor: '#ffffff',
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
it('renders header with correct structure', () => {
|
|
95
|
+
const { getByTestId, getByText } = render(
|
|
96
|
+
<DisclaimerModal
|
|
97
|
+
visible={true}
|
|
98
|
+
title="Test Title"
|
|
99
|
+
content="Test Content"
|
|
100
|
+
onClose={jest.fn()}
|
|
101
|
+
/>
|
|
102
|
+
);
|
|
103
|
+
|
|
104
|
+
expect(getByTestId('atomic-text-headlineMedium-primary')).toBeTruthy();
|
|
105
|
+
expect(getByTestId('atomic-icon-X-primary-md')).toBeTruthy();
|
|
106
|
+
expect(getByText('Test Title')).toBeTruthy();
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
it('renders content in ScrollView', () => {
|
|
110
|
+
const { getByTestId } = render(
|
|
111
|
+
<DisclaimerModal
|
|
112
|
+
visible={true}
|
|
113
|
+
title="Test Title"
|
|
114
|
+
content="Test Content"
|
|
115
|
+
onClose={jest.fn()}
|
|
116
|
+
/>
|
|
117
|
+
);
|
|
118
|
+
|
|
119
|
+
expect(getByTestId('disclaimer-modal-content')).toBeTruthy();
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
it('handles long content correctly', () => {
|
|
123
|
+
const longContent = 'This is a very long disclaimer content that should scroll properly. '.repeat(20);
|
|
124
|
+
|
|
125
|
+
const { getByText } = render(
|
|
126
|
+
<DisclaimerModal
|
|
127
|
+
visible={true}
|
|
128
|
+
title="Test Title"
|
|
129
|
+
content={longContent}
|
|
130
|
+
onClose={jest.fn()}
|
|
131
|
+
/>
|
|
132
|
+
);
|
|
133
|
+
|
|
134
|
+
expect(getByText(longContent)).toBeTruthy();
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
it('applies correct text styling', () => {
|
|
138
|
+
const { getByTestId } = render(
|
|
139
|
+
<DisclaimerModal
|
|
140
|
+
visible={true}
|
|
141
|
+
title="Test Title"
|
|
142
|
+
content="Test Content"
|
|
143
|
+
onClose={jest.fn()}
|
|
144
|
+
/>
|
|
145
|
+
);
|
|
146
|
+
|
|
147
|
+
expect(getByTestId('atomic-text-bodyMedium-primary')).toBeTruthy();
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
it('has correct accessibility properties', () => {
|
|
151
|
+
const mockOnClose = jest.fn();
|
|
152
|
+
const { getByTestId } = render(
|
|
153
|
+
<DisclaimerModal
|
|
154
|
+
visible={true}
|
|
155
|
+
title="Test Title"
|
|
156
|
+
content="Test Content"
|
|
157
|
+
onClose={mockOnClose}
|
|
158
|
+
/>
|
|
159
|
+
);
|
|
160
|
+
|
|
161
|
+
const closeButton = getByTestId('close-disclaimer-modal');
|
|
162
|
+
expect(closeButton).toBeTruthy();
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
it('handles multiple close calls', () => {
|
|
166
|
+
const mockOnClose = jest.fn();
|
|
167
|
+
const { getByTestId } = render(
|
|
168
|
+
<DisclaimerModal
|
|
169
|
+
visible={true}
|
|
170
|
+
title="Test Title"
|
|
171
|
+
content="Test Content"
|
|
172
|
+
onClose={mockOnClose}
|
|
173
|
+
/>
|
|
174
|
+
);
|
|
175
|
+
|
|
176
|
+
const closeButton = getByTestId('close-disclaimer-modal');
|
|
177
|
+
|
|
178
|
+
fireEvent.press(closeButton);
|
|
179
|
+
fireEvent.press(closeButton);
|
|
180
|
+
fireEvent.press(closeButton);
|
|
181
|
+
|
|
182
|
+
expect(mockOnClose).toHaveBeenCalledTimes(3);
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
it('maintains correct layout structure', () => {
|
|
186
|
+
const { getByTestId } = render(
|
|
187
|
+
<DisclaimerModal
|
|
188
|
+
visible={true}
|
|
189
|
+
title="Test Title"
|
|
190
|
+
content="Test Content"
|
|
191
|
+
onClose={jest.fn()}
|
|
192
|
+
/>
|
|
193
|
+
);
|
|
194
|
+
|
|
195
|
+
// Check modal container exists
|
|
196
|
+
expect(getByTestId('disclaimer-modal')).toBeTruthy();
|
|
197
|
+
|
|
198
|
+
// Check header elements exist
|
|
199
|
+
expect(getByTestId('atomic-text-headlineMedium-primary')).toBeTruthy();
|
|
200
|
+
expect(getByTestId('atomic-icon-X-primary-md')).toBeTruthy();
|
|
201
|
+
|
|
202
|
+
// Check content exists
|
|
203
|
+
expect(getByTestId('disclaimer-modal-content')).toBeTruthy();
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
it('handles empty content gracefully', () => {
|
|
207
|
+
const { getByTestId, queryByText } = render(
|
|
208
|
+
<DisclaimerModal
|
|
209
|
+
visible={true}
|
|
210
|
+
title="Test Title"
|
|
211
|
+
content=""
|
|
212
|
+
onClose={jest.fn()}
|
|
213
|
+
/>
|
|
214
|
+
);
|
|
215
|
+
|
|
216
|
+
expect(getByTestId('disclaimer-modal')).toBeTruthy();
|
|
217
|
+
expect(getByTestId('atomic-text-headlineMedium-primary')).toBeTruthy();
|
|
218
|
+
// Empty content should still render the text component
|
|
219
|
+
expect(getByTestId('atomic-text-bodyMedium-primary')).toBeTruthy();
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
it('handles special characters in content', () => {
|
|
223
|
+
const specialContent = 'Content with special chars: © ® ™ "quotes" \'apostrophes\'';
|
|
224
|
+
|
|
225
|
+
const { getByText } = render(
|
|
226
|
+
<DisclaimerModal
|
|
227
|
+
visible={true}
|
|
228
|
+
title="Test Title"
|
|
229
|
+
content={specialContent}
|
|
230
|
+
onClose={jest.fn()}
|
|
231
|
+
/>
|
|
232
|
+
);
|
|
233
|
+
|
|
234
|
+
expect(getByText(specialContent)).toBeTruthy();
|
|
235
|
+
});
|
|
236
|
+
});
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tests for DisclaimerSetting Component
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import { render, fireEvent } from '@testing-library/react-native';
|
|
7
|
+
import { DisclaimerSetting } from '../DisclaimerSetting';
|
|
8
|
+
|
|
9
|
+
// Mock dependencies
|
|
10
|
+
jest.mock('@umituz/react-native-localization', () => ({
|
|
11
|
+
useLocalization: () => ({
|
|
12
|
+
t: (key: string) => key,
|
|
13
|
+
}),
|
|
14
|
+
}));
|
|
15
|
+
|
|
16
|
+
jest.mock('@umituz/react-native-design-system-theme', () => ({
|
|
17
|
+
useAppDesignTokens: () => ({
|
|
18
|
+
colors: {
|
|
19
|
+
backgroundPrimary: '#ffffff',
|
|
20
|
+
warning: '#ff9800',
|
|
21
|
+
},
|
|
22
|
+
spacing: {
|
|
23
|
+
md: 16,
|
|
24
|
+
},
|
|
25
|
+
}),
|
|
26
|
+
withAlpha: (color: string, alpha: number) => `${color}${alpha}`,
|
|
27
|
+
}));
|
|
28
|
+
|
|
29
|
+
describe('DisclaimerSetting', () => {
|
|
30
|
+
it('renders disclaimer card correctly', () => {
|
|
31
|
+
const { getByTestId } = render(<DisclaimerSetting />);
|
|
32
|
+
|
|
33
|
+
expect(getByTestId('disclaimer-setting')).toBeTruthy();
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it('opens modal when card is pressed', () => {
|
|
37
|
+
const { getByTestId } = render(<DisclaimerSetting />);
|
|
38
|
+
|
|
39
|
+
const card = getByTestId('disclaimer-setting');
|
|
40
|
+
fireEvent.press(card);
|
|
41
|
+
|
|
42
|
+
// Modal should be visible now
|
|
43
|
+
expect(getByTestId('close-disclaimer-modal')).toBeTruthy();
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it('closes modal when close button is pressed', () => {
|
|
47
|
+
const { getByTestId } = render(<DisclaimerSetting />);
|
|
48
|
+
|
|
49
|
+
// Open modal first
|
|
50
|
+
const card = getByTestId('disclaimer-setting');
|
|
51
|
+
fireEvent.press(card);
|
|
52
|
+
|
|
53
|
+
// Close modal
|
|
54
|
+
const closeButton = getByTestId('close-disclaimer-modal');
|
|
55
|
+
fireEvent.press(closeButton);
|
|
56
|
+
|
|
57
|
+
// Modal should be closed
|
|
58
|
+
expect(() => getByTestId('close-disclaimer-modal')).toThrow();
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it('uses custom props when provided', () => {
|
|
62
|
+
const customProps = {
|
|
63
|
+
titleKey: 'custom.title',
|
|
64
|
+
messageKey: 'custom.message',
|
|
65
|
+
shortMessageKey: 'custom.shortMessage',
|
|
66
|
+
iconName: 'Info',
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
const { getByText } = render(<DisclaimerSetting {...customProps} />);
|
|
70
|
+
|
|
71
|
+
expect(getByText('custom.title')).toBeTruthy();
|
|
72
|
+
expect(getByText('custom.shortMessage')).toBeTruthy();
|
|
73
|
+
});
|
|
74
|
+
});
|