@umituz/react-native-settings 2.0.0 → 2.4.1

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.
Files changed (160) hide show
  1. package/README.md +129 -3
  2. package/lib/__tests__/setup.d.ts +5 -0
  3. package/lib/__tests__/setup.d.ts.map +1 -0
  4. package/lib/__tests__/setup.js +143 -0
  5. package/lib/__tests__/setup.js.map +1 -0
  6. package/lib/domain/repositories/ISettingsRepository.d.ts +51 -0
  7. package/lib/domain/repositories/ISettingsRepository.d.ts.map +1 -0
  8. package/lib/domain/repositories/ISettingsRepository.js +8 -0
  9. package/lib/domain/repositories/ISettingsRepository.js.map +1 -0
  10. package/lib/index.d.ts +35 -0
  11. package/lib/index.d.ts.map +1 -0
  12. package/lib/index.js +32 -0
  13. package/lib/index.js.map +1 -0
  14. package/lib/infrastructure/storage/SettingsStore.d.ts +36 -0
  15. package/lib/infrastructure/storage/SettingsStore.d.ts.map +1 -0
  16. package/lib/infrastructure/storage/SettingsStore.js +144 -0
  17. package/lib/infrastructure/storage/SettingsStore.js.map +1 -0
  18. package/lib/presentation/components/CloudSyncSetting.d.ts +16 -0
  19. package/lib/presentation/components/CloudSyncSetting.d.ts.map +1 -0
  20. package/lib/presentation/components/CloudSyncSetting.js +30 -0
  21. package/lib/presentation/components/CloudSyncSetting.js.map +1 -0
  22. package/lib/presentation/components/DisclaimerCard.d.ts +15 -0
  23. package/lib/presentation/components/DisclaimerCard.d.ts.map +1 -0
  24. package/lib/presentation/components/DisclaimerCard.js +73 -0
  25. package/lib/presentation/components/DisclaimerCard.js.map +1 -0
  26. package/lib/presentation/components/DisclaimerModal.d.ts +13 -0
  27. package/lib/presentation/components/DisclaimerModal.d.ts.map +1 -0
  28. package/lib/presentation/components/DisclaimerModal.js +62 -0
  29. package/lib/presentation/components/DisclaimerModal.js.map +1 -0
  30. package/lib/presentation/components/DisclaimerSetting.d.ts +39 -0
  31. package/lib/presentation/components/DisclaimerSetting.d.ts.map +1 -0
  32. package/lib/presentation/components/DisclaimerSetting.js +59 -0
  33. package/lib/presentation/components/DisclaimerSetting.js.map +1 -0
  34. package/lib/presentation/components/SettingItem.d.ts +45 -0
  35. package/lib/presentation/components/SettingItem.d.ts.map +1 -0
  36. package/lib/presentation/components/SettingItem.js +113 -0
  37. package/lib/presentation/components/SettingItem.js.map +1 -0
  38. package/lib/presentation/components/SettingsErrorBoundary.d.ts +23 -0
  39. package/lib/presentation/components/SettingsErrorBoundary.d.ts.map +1 -0
  40. package/lib/presentation/components/SettingsErrorBoundary.js +73 -0
  41. package/lib/presentation/components/SettingsErrorBoundary.js.map +1 -0
  42. package/lib/presentation/components/SettingsFooter.d.ts +11 -0
  43. package/lib/presentation/components/SettingsFooter.d.ts.map +1 -0
  44. package/lib/presentation/components/SettingsFooter.js +31 -0
  45. package/lib/presentation/components/SettingsFooter.js.map +1 -0
  46. package/lib/presentation/components/SettingsSection.d.ts +13 -0
  47. package/lib/presentation/components/SettingsSection.d.ts.map +1 -0
  48. package/lib/presentation/components/SettingsSection.js +37 -0
  49. package/lib/presentation/components/SettingsSection.js.map +1 -0
  50. package/lib/presentation/components/StorageClearSetting.d.ts +16 -0
  51. package/lib/presentation/components/StorageClearSetting.d.ts.map +1 -0
  52. package/lib/presentation/components/StorageClearSetting.js +21 -0
  53. package/lib/presentation/components/StorageClearSetting.js.map +1 -0
  54. package/lib/presentation/components/UserProfileHeader.d.ts +30 -0
  55. package/lib/presentation/components/UserProfileHeader.d.ts.map +1 -0
  56. package/lib/presentation/components/UserProfileHeader.js +119 -0
  57. package/lib/presentation/components/UserProfileHeader.js.map +1 -0
  58. package/lib/presentation/screens/AppearanceScreen.d.ts +8 -0
  59. package/lib/presentation/screens/AppearanceScreen.d.ts.map +1 -0
  60. package/lib/presentation/screens/AppearanceScreen.js +8 -0
  61. package/lib/presentation/screens/AppearanceScreen.js.map +1 -0
  62. package/lib/presentation/screens/SettingsScreen.d.ts +38 -0
  63. package/lib/presentation/screens/SettingsScreen.d.ts.map +1 -0
  64. package/lib/presentation/screens/SettingsScreen.js +37 -0
  65. package/lib/presentation/screens/SettingsScreen.js.map +1 -0
  66. package/lib/presentation/screens/components/AboutLegalSection.d.ts +15 -0
  67. package/lib/presentation/screens/components/AboutLegalSection.d.ts.map +1 -0
  68. package/lib/presentation/screens/components/AboutLegalSection.js +28 -0
  69. package/lib/presentation/screens/components/AboutLegalSection.js.map +1 -0
  70. package/lib/presentation/screens/components/AppearanceSection.d.ts +12 -0
  71. package/lib/presentation/screens/components/AppearanceSection.d.ts.map +1 -0
  72. package/lib/presentation/screens/components/AppearanceSection.js +21 -0
  73. package/lib/presentation/screens/components/AppearanceSection.js.map +1 -0
  74. package/lib/presentation/screens/components/LanguageSection.d.ts +12 -0
  75. package/lib/presentation/screens/components/LanguageSection.d.ts.map +1 -0
  76. package/lib/presentation/screens/components/LanguageSection.js +26 -0
  77. package/lib/presentation/screens/components/LanguageSection.js.map +1 -0
  78. package/lib/presentation/screens/components/NotificationsSection.d.ts +12 -0
  79. package/lib/presentation/screens/components/NotificationsSection.d.ts.map +1 -0
  80. package/lib/presentation/screens/components/NotificationsSection.js +58 -0
  81. package/lib/presentation/screens/components/NotificationsSection.js.map +1 -0
  82. package/lib/presentation/screens/components/SettingsContent.d.ts +36 -0
  83. package/lib/presentation/screens/components/SettingsContent.d.ts.map +1 -0
  84. package/lib/presentation/screens/components/SettingsContent.js +81 -0
  85. package/lib/presentation/screens/components/SettingsContent.js.map +1 -0
  86. package/lib/presentation/screens/components/SettingsHeader.d.ts +12 -0
  87. package/lib/presentation/screens/components/SettingsHeader.d.ts.map +1 -0
  88. package/lib/presentation/screens/components/SettingsHeader.js +59 -0
  89. package/lib/presentation/screens/components/SettingsHeader.js.map +1 -0
  90. package/lib/presentation/screens/components/index.d.ts +9 -0
  91. package/lib/presentation/screens/components/index.d.ts.map +1 -0
  92. package/lib/presentation/screens/components/index.js +9 -0
  93. package/lib/presentation/screens/components/index.js.map +1 -0
  94. package/lib/presentation/screens/hooks/useFeatureDetection.d.ts +21 -0
  95. package/lib/presentation/screens/hooks/useFeatureDetection.d.ts.map +1 -0
  96. package/lib/presentation/screens/hooks/useFeatureDetection.js +82 -0
  97. package/lib/presentation/screens/hooks/useFeatureDetection.js.map +1 -0
  98. package/lib/presentation/screens/types/CustomSection.d.ts +19 -0
  99. package/lib/presentation/screens/types/CustomSection.d.ts.map +1 -0
  100. package/lib/presentation/screens/types/CustomSection.js +6 -0
  101. package/lib/presentation/screens/types/CustomSection.js.map +1 -0
  102. package/lib/presentation/screens/types/ExtendedConfig.d.ts +68 -0
  103. package/lib/presentation/screens/types/ExtendedConfig.d.ts.map +1 -0
  104. package/lib/presentation/screens/types/ExtendedConfig.js +6 -0
  105. package/lib/presentation/screens/types/ExtendedConfig.js.map +1 -0
  106. package/lib/presentation/screens/types/FeatureConfig.d.ts +95 -0
  107. package/lib/presentation/screens/types/FeatureConfig.d.ts.map +1 -0
  108. package/lib/presentation/screens/types/FeatureConfig.js +6 -0
  109. package/lib/presentation/screens/types/FeatureConfig.js.map +1 -0
  110. package/lib/presentation/screens/types/SettingsConfig.d.ts +97 -0
  111. package/lib/presentation/screens/types/SettingsConfig.d.ts.map +1 -0
  112. package/lib/presentation/screens/types/SettingsConfig.js +6 -0
  113. package/lib/presentation/screens/types/SettingsConfig.js.map +1 -0
  114. package/lib/presentation/screens/types/index.d.ts +10 -0
  115. package/lib/presentation/screens/types/index.d.ts.map +1 -0
  116. package/lib/presentation/screens/types/index.js +6 -0
  117. package/lib/presentation/screens/types/index.js.map +1 -0
  118. package/lib/presentation/screens/utils/normalizeConfig.d.ts +44 -0
  119. package/lib/presentation/screens/utils/normalizeConfig.d.ts.map +1 -0
  120. package/lib/presentation/screens/utils/normalizeConfig.js +38 -0
  121. package/lib/presentation/screens/utils/normalizeConfig.js.map +1 -0
  122. package/package.json +46 -11
  123. package/src/__tests__/integration.test.tsx +371 -0
  124. package/src/__tests__/performance.test.tsx +369 -0
  125. package/src/__tests__/setup.test.tsx +20 -0
  126. package/src/__tests__/setup.ts +157 -0
  127. package/src/index.ts +9 -0
  128. package/src/infrastructure/storage/SettingsStore.ts +90 -45
  129. package/src/infrastructure/storage/__tests__/SettingsStore.test.tsx +302 -0
  130. package/src/presentation/components/CloudSyncSetting.tsx +11 -17
  131. package/src/presentation/components/DisclaimerCard.tsx +115 -0
  132. package/src/presentation/components/DisclaimerModal.tsx +104 -0
  133. package/src/presentation/components/DisclaimerSetting.tsx +77 -159
  134. package/src/presentation/components/SettingItem.tsx +11 -2
  135. package/src/presentation/components/SettingsErrorBoundary.tsx +126 -0
  136. package/src/presentation/components/StorageClearSetting.tsx +13 -8
  137. package/src/presentation/components/UserProfileHeader.tsx +48 -11
  138. package/src/presentation/components/__tests__/CloudSyncSetting.test.tsx +78 -0
  139. package/src/presentation/components/__tests__/DisclaimerCard.test.tsx +208 -0
  140. package/src/presentation/components/__tests__/DisclaimerModal.test.tsx +236 -0
  141. package/src/presentation/components/__tests__/DisclaimerSetting.test.tsx +74 -0
  142. package/src/presentation/components/__tests__/SettingItem.test.tsx +189 -0
  143. package/src/presentation/components/__tests__/SettingsErrorBoundary.test.tsx +186 -0
  144. package/src/presentation/screens/SettingsScreen.tsx +29 -159
  145. package/src/presentation/screens/__tests__/SettingsScreen.test.tsx +322 -0
  146. package/src/presentation/screens/components/AboutLegalSection.tsx +14 -5
  147. package/src/presentation/screens/components/AppearanceSection.tsx +1 -1
  148. package/src/presentation/screens/components/LanguageSection.tsx +2 -1
  149. package/src/presentation/screens/components/NotificationsSection.tsx +19 -14
  150. package/src/presentation/screens/components/SettingsContent.tsx +167 -0
  151. package/src/presentation/screens/components/SettingsHeader.tsx +79 -0
  152. package/src/presentation/screens/hooks/__tests__/useFeatureDetection.test.tsx +261 -0
  153. package/src/presentation/screens/hooks/useFeatureDetection.ts +15 -5
  154. package/src/presentation/screens/types/CustomSection.ts +20 -0
  155. package/src/presentation/screens/types/ExtendedConfig.ts +68 -0
  156. package/src/presentation/screens/types/FeatureConfig.ts +102 -0
  157. package/src/presentation/screens/types/SettingsConfig.ts +116 -0
  158. package/src/presentation/screens/types/index.ts +20 -0
  159. package/src/presentation/screens/utils/normalizeConfig.ts +2 -1
  160. 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
+ });