@adobe/react-native-aepmessaging 7.3.0 → 7.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.
Files changed (289) hide show
  1. package/RCTAEPMessaging.podspec +1 -1
  2. package/README.md +145 -16
  3. package/android/src/main/java/com/adobe/marketing/mobile/reactnative/messaging/RCTAEPMessagingModule.java +82 -32
  4. package/babel.config.js +3 -0
  5. package/dist/module/Messaging.js +334 -0
  6. package/dist/module/Messaging.js.map +1 -0
  7. package/dist/module/index.js +30 -0
  8. package/dist/module/index.js.map +1 -0
  9. package/dist/module/models/ContentCard.js +24 -0
  10. package/dist/module/models/ContentCard.js.map +1 -0
  11. package/dist/{models → module/models}/HTMLProposition.js +8 -9
  12. package/dist/module/models/HTMLProposition.js.map +1 -0
  13. package/dist/module/models/InAppMessage.js +4 -0
  14. package/dist/module/models/InAppMessage.js.map +1 -0
  15. package/dist/module/models/JSONProposition.js +22 -0
  16. package/dist/module/models/JSONProposition.js.map +1 -0
  17. package/dist/module/models/Message.js +182 -0
  18. package/dist/module/models/Message.js.map +1 -0
  19. package/dist/module/models/MessagingDelegate.js +4 -0
  20. package/dist/module/models/MessagingDelegate.js.map +1 -0
  21. package/dist/module/models/MessagingEdgeEventType.js +24 -0
  22. package/dist/module/models/MessagingEdgeEventType.js.map +1 -0
  23. package/dist/module/models/MessagingProposition.js +57 -0
  24. package/dist/module/models/MessagingProposition.js.map +1 -0
  25. package/dist/module/models/MessagingPropositionItem.js +4 -0
  26. package/dist/module/models/MessagingPropositionItem.js.map +1 -0
  27. package/dist/module/models/PersonalizationSchema.js +26 -0
  28. package/dist/module/models/PersonalizationSchema.js.map +1 -0
  29. package/dist/module/models/PropositionItem.js +113 -0
  30. package/dist/module/models/PropositionItem.js.map +1 -0
  31. package/dist/module/models/ScopeDetails.js +2 -0
  32. package/dist/module/models/ScopeDetails.js.map +1 -0
  33. package/dist/{models/JSONProposition.js → module/models/index.js} +14 -12
  34. package/dist/module/models/index.js.map +1 -0
  35. package/dist/module/ui/components/Button/Button.js +57 -0
  36. package/dist/module/ui/components/Button/Button.js.map +1 -0
  37. package/dist/module/ui/components/Button/Button.spec.js +476 -0
  38. package/dist/module/ui/components/Button/Button.spec.js.map +1 -0
  39. package/dist/module/ui/components/ContentCardView/ContentCardView.js +257 -0
  40. package/dist/module/ui/components/ContentCardView/ContentCardView.js.map +1 -0
  41. package/dist/module/ui/components/ContentCardView/ContentCardView.spec.js +363 -0
  42. package/dist/module/ui/components/ContentCardView/ContentCardView.spec.js.map +1 -0
  43. package/dist/module/ui/components/DismissButton/DismissButton.js +70 -0
  44. package/dist/module/ui/components/DismissButton/DismissButton.js.map +1 -0
  45. package/dist/module/ui/components/DismissButton/DismissButton.spec.js +279 -0
  46. package/dist/module/ui/components/DismissButton/DismissButton.spec.js.map +1 -0
  47. package/dist/module/ui/components/FullScreenCenterView/FullScreenCenterView.js +34 -0
  48. package/dist/module/ui/components/FullScreenCenterView/FullScreenCenterView.js.map +1 -0
  49. package/dist/module/ui/components/Inbox/EmptyState.js +64 -0
  50. package/dist/module/ui/components/Inbox/EmptyState.js.map +1 -0
  51. package/dist/module/ui/components/Inbox/Inbox.js +235 -0
  52. package/dist/module/ui/components/Inbox/Inbox.js.map +1 -0
  53. package/dist/module/ui/components/Inbox/Inbox.spec.js +847 -0
  54. package/dist/module/ui/components/Inbox/Inbox.spec.js.map +1 -0
  55. package/dist/module/ui/components/Pagination/Pagination.js +176 -0
  56. package/dist/module/ui/components/Pagination/Pagination.js.map +1 -0
  57. package/dist/module/ui/components/Pagination/Pagination.spec.js +193 -0
  58. package/dist/module/ui/components/Pagination/Pagination.spec.js.map +1 -0
  59. package/dist/module/ui/components/UnreadIcon/UnreadIcon.js +184 -0
  60. package/dist/module/ui/components/UnreadIcon/UnreadIcon.js.map +1 -0
  61. package/dist/module/ui/components/UnreadIcon/UnreadIcon.spec.js +815 -0
  62. package/dist/module/ui/components/UnreadIcon/UnreadIcon.spec.js.map +1 -0
  63. package/dist/{models/ContentCard.js → module/ui/components/index.js} +12 -12
  64. package/dist/module/ui/components/index.js.map +1 -0
  65. package/dist/module/ui/hooks/index.js +18 -0
  66. package/dist/module/ui/hooks/index.js.map +1 -0
  67. package/dist/module/ui/hooks/useAspectRatio.js +33 -0
  68. package/dist/module/ui/hooks/useAspectRatio.js.map +1 -0
  69. package/dist/module/ui/hooks/useAspectRatio.spec.js +65 -0
  70. package/dist/module/ui/hooks/useAspectRatio.spec.js.map +1 -0
  71. package/dist/module/ui/hooks/useContentCardUI.js +51 -0
  72. package/dist/module/ui/hooks/useContentCardUI.js.map +1 -0
  73. package/dist/module/ui/hooks/useContentCardUI.spec.js +85 -0
  74. package/dist/module/ui/hooks/useContentCardUI.spec.js.map +1 -0
  75. package/dist/module/ui/hooks/useInbox.js +49 -0
  76. package/dist/module/ui/hooks/useInbox.js.map +1 -0
  77. package/dist/module/ui/hooks/useInbox.spec.js +93 -0
  78. package/dist/module/ui/hooks/useInbox.spec.js.map +1 -0
  79. package/dist/module/ui/hooks/useInboxSettings.js +26 -0
  80. package/dist/module/ui/hooks/useInboxSettings.js.map +1 -0
  81. package/dist/module/ui/hooks/useInboxSettings.spec.js +50 -0
  82. package/dist/module/ui/hooks/useInboxSettings.spec.js.map +1 -0
  83. package/dist/module/ui/index.js +10 -0
  84. package/dist/module/ui/index.js.map +1 -0
  85. package/dist/module/ui/providers/InboxProvider.js +27 -0
  86. package/dist/module/ui/providers/InboxProvider.js.map +1 -0
  87. package/dist/module/ui/theme/Theme.js +2 -0
  88. package/dist/module/ui/theme/Theme.js.map +1 -0
  89. package/dist/module/ui/theme/ThemeProvider.js +112 -0
  90. package/dist/module/ui/theme/ThemeProvider.js.map +1 -0
  91. package/dist/{models/InAppMessage.js → module/ui/theme/index.js} +6 -3
  92. package/dist/module/ui/theme/index.js.map +1 -0
  93. package/dist/module/ui/types/ContentViewEvent.js +2 -0
  94. package/dist/module/ui/types/ContentViewEvent.js.map +1 -0
  95. package/dist/module/ui/types/Templates.js +26 -0
  96. package/dist/module/ui/types/Templates.js.map +1 -0
  97. package/dist/{models/ScopeDetails.js → module/ui/types/index.js} +6 -3
  98. package/dist/module/ui/types/index.js.map +1 -0
  99. package/dist/module/ui/utils/generateCardHash.js +50 -0
  100. package/dist/module/ui/utils/generateCardHash.js.map +1 -0
  101. package/dist/module/ui/utils/generateCardHash.spec.js +103 -0
  102. package/dist/module/ui/utils/generateCardHash.spec.js.map +1 -0
  103. package/dist/module/ui/utils/inboxStorage.js +65 -0
  104. package/dist/module/ui/utils/inboxStorage.js.map +1 -0
  105. package/dist/module/ui/utils/inboxStorage.spec.js +123 -0
  106. package/dist/module/ui/utils/inboxStorage.spec.js.map +1 -0
  107. package/dist/module/ui/utils/index.js +5 -0
  108. package/dist/module/ui/utils/index.js.map +1 -0
  109. package/dist/{Messaging.d.ts → typescript/Messaging.d.ts} +23 -7
  110. package/dist/typescript/Messaging.d.ts.map +1 -0
  111. package/dist/{index.d.ts → typescript/index.d.ts} +4 -2
  112. package/dist/typescript/index.d.ts.map +1 -0
  113. package/dist/typescript/models/ContentCard.d.ts +57 -0
  114. package/dist/typescript/models/ContentCard.d.ts.map +1 -0
  115. package/dist/{models → typescript/models}/HTMLProposition.d.ts +1 -0
  116. package/dist/typescript/models/HTMLProposition.d.ts.map +1 -0
  117. package/dist/{models → typescript/models}/InAppMessage.d.ts +1 -0
  118. package/dist/typescript/models/InAppMessage.d.ts.map +1 -0
  119. package/dist/{models → typescript/models}/JSONProposition.d.ts +1 -0
  120. package/dist/typescript/models/JSONProposition.d.ts.map +1 -0
  121. package/dist/{models → typescript/models}/Message.d.ts +1 -0
  122. package/dist/typescript/models/Message.d.ts.map +1 -0
  123. package/dist/{models → typescript/models}/MessagingDelegate.d.ts +1 -0
  124. package/dist/typescript/models/MessagingDelegate.d.ts.map +1 -0
  125. package/dist/{models → typescript/models}/MessagingEdgeEventType.d.ts +1 -0
  126. package/dist/typescript/models/MessagingEdgeEventType.d.ts.map +1 -0
  127. package/dist/{models → typescript/models}/MessagingProposition.d.ts +1 -0
  128. package/dist/typescript/models/MessagingProposition.d.ts.map +1 -0
  129. package/dist/{models → typescript/models}/MessagingPropositionItem.d.ts +1 -0
  130. package/dist/typescript/models/MessagingPropositionItem.d.ts.map +1 -0
  131. package/dist/{models → typescript/models}/PersonalizationSchema.d.ts +2 -0
  132. package/dist/typescript/models/PersonalizationSchema.d.ts.map +1 -0
  133. package/dist/{models → typescript/models}/PropositionItem.d.ts +1 -0
  134. package/dist/typescript/models/PropositionItem.d.ts.map +1 -0
  135. package/dist/{models → typescript/models}/ScopeDetails.d.ts +1 -0
  136. package/dist/typescript/models/ScopeDetails.d.ts.map +1 -0
  137. package/dist/typescript/models/index.d.ts +11 -0
  138. package/dist/typescript/models/index.d.ts.map +1 -0
  139. package/dist/typescript/ui/components/Button/Button.d.ts +14 -0
  140. package/dist/typescript/ui/components/Button/Button.d.ts.map +1 -0
  141. package/dist/typescript/ui/components/Button/Button.spec.d.ts +2 -0
  142. package/dist/typescript/ui/components/Button/Button.spec.d.ts.map +1 -0
  143. package/dist/typescript/ui/components/ContentCardView/ContentCardView.d.ts +39 -0
  144. package/dist/typescript/ui/components/ContentCardView/ContentCardView.d.ts.map +1 -0
  145. package/dist/typescript/ui/components/ContentCardView/ContentCardView.spec.d.ts +2 -0
  146. package/dist/typescript/ui/components/ContentCardView/ContentCardView.spec.d.ts.map +1 -0
  147. package/dist/typescript/ui/components/DismissButton/DismissButton.d.ts +13 -0
  148. package/dist/typescript/ui/components/DismissButton/DismissButton.d.ts.map +1 -0
  149. package/dist/typescript/ui/components/DismissButton/DismissButton.spec.d.ts +2 -0
  150. package/dist/typescript/ui/components/DismissButton/DismissButton.spec.d.ts.map +1 -0
  151. package/dist/typescript/ui/components/FullScreenCenterView/FullScreenCenterView.d.ts +5 -0
  152. package/dist/typescript/ui/components/FullScreenCenterView/FullScreenCenterView.d.ts.map +1 -0
  153. package/dist/typescript/ui/components/Inbox/EmptyState.d.ts +19 -0
  154. package/dist/typescript/ui/components/Inbox/EmptyState.d.ts.map +1 -0
  155. package/dist/typescript/ui/components/Inbox/Inbox.d.ts +21 -0
  156. package/dist/typescript/ui/components/Inbox/Inbox.d.ts.map +1 -0
  157. package/dist/typescript/ui/components/Inbox/Inbox.spec.d.ts +2 -0
  158. package/dist/typescript/ui/components/Inbox/Inbox.spec.d.ts.map +1 -0
  159. package/dist/typescript/ui/components/Pagination/Pagination.d.ts +14 -0
  160. package/dist/typescript/ui/components/Pagination/Pagination.d.ts.map +1 -0
  161. package/dist/typescript/ui/components/Pagination/Pagination.spec.d.ts +2 -0
  162. package/dist/typescript/ui/components/Pagination/Pagination.spec.d.ts.map +1 -0
  163. package/dist/typescript/ui/components/UnreadIcon/UnreadIcon.d.ts +14 -0
  164. package/dist/typescript/ui/components/UnreadIcon/UnreadIcon.d.ts.map +1 -0
  165. package/dist/typescript/ui/components/UnreadIcon/UnreadIcon.spec.d.ts +2 -0
  166. package/dist/typescript/ui/components/UnreadIcon/UnreadIcon.spec.d.ts.map +1 -0
  167. package/dist/typescript/ui/components/index.d.ts +10 -0
  168. package/dist/typescript/ui/components/index.d.ts.map +1 -0
  169. package/dist/typescript/ui/hooks/index.d.ts +4 -0
  170. package/dist/typescript/ui/hooks/index.d.ts.map +1 -0
  171. package/dist/typescript/ui/hooks/useAspectRatio.d.ts +3 -0
  172. package/dist/typescript/ui/hooks/useAspectRatio.d.ts.map +1 -0
  173. package/dist/typescript/ui/hooks/useAspectRatio.spec.d.ts +2 -0
  174. package/dist/typescript/ui/hooks/useAspectRatio.spec.d.ts.map +1 -0
  175. package/dist/typescript/ui/hooks/useContentCardUI.d.ts +14 -0
  176. package/dist/typescript/ui/hooks/useContentCardUI.d.ts.map +1 -0
  177. package/dist/typescript/ui/hooks/useContentCardUI.spec.d.ts +2 -0
  178. package/dist/typescript/ui/hooks/useContentCardUI.spec.d.ts.map +1 -0
  179. package/dist/typescript/ui/hooks/useInbox.d.ts +12 -0
  180. package/dist/typescript/ui/hooks/useInbox.d.ts.map +1 -0
  181. package/dist/typescript/ui/hooks/useInbox.spec.d.ts +2 -0
  182. package/dist/typescript/ui/hooks/useInbox.spec.d.ts.map +1 -0
  183. package/dist/typescript/ui/hooks/useInboxSettings.d.ts +7 -0
  184. package/dist/typescript/ui/hooks/useInboxSettings.d.ts.map +1 -0
  185. package/dist/typescript/ui/hooks/useInboxSettings.spec.d.ts +2 -0
  186. package/dist/typescript/ui/hooks/useInboxSettings.spec.d.ts.map +1 -0
  187. package/dist/typescript/ui/index.d.ts +8 -0
  188. package/dist/typescript/ui/index.d.ts.map +1 -0
  189. package/dist/typescript/ui/providers/InboxProvider.d.ts +56 -0
  190. package/dist/typescript/ui/providers/InboxProvider.d.ts.map +1 -0
  191. package/dist/typescript/ui/theme/Theme.d.ts +44 -0
  192. package/dist/typescript/ui/theme/Theme.d.ts.map +1 -0
  193. package/dist/typescript/ui/theme/ThemeProvider.d.ts +21 -0
  194. package/dist/typescript/ui/theme/ThemeProvider.d.ts.map +1 -0
  195. package/dist/typescript/ui/theme/index.d.ts +3 -0
  196. package/dist/typescript/ui/theme/index.d.ts.map +1 -0
  197. package/dist/typescript/ui/types/ContentViewEvent.d.ts +9 -0
  198. package/dist/typescript/ui/types/ContentViewEvent.d.ts.map +1 -0
  199. package/dist/typescript/ui/types/Templates.d.ts +43 -0
  200. package/dist/typescript/ui/types/Templates.d.ts.map +1 -0
  201. package/dist/typescript/ui/types/index.d.ts +3 -0
  202. package/dist/typescript/ui/types/index.d.ts.map +1 -0
  203. package/dist/typescript/ui/utils/generateCardHash.d.ts +21 -0
  204. package/dist/typescript/ui/utils/generateCardHash.d.ts.map +1 -0
  205. package/dist/typescript/ui/utils/generateCardHash.spec.d.ts +2 -0
  206. package/dist/typescript/ui/utils/generateCardHash.spec.d.ts.map +1 -0
  207. package/dist/typescript/ui/utils/inboxStorage.d.ts +20 -0
  208. package/dist/typescript/ui/utils/inboxStorage.d.ts.map +1 -0
  209. package/dist/typescript/ui/utils/inboxStorage.spec.d.ts +2 -0
  210. package/dist/typescript/ui/utils/inboxStorage.spec.d.ts.map +1 -0
  211. package/dist/typescript/ui/utils/index.d.ts +3 -0
  212. package/dist/typescript/ui/utils/index.d.ts.map +1 -0
  213. package/ios/src/RCTAEPMessaging.mm +11 -0
  214. package/ios/src/RCTAEPMessaging.swift +30 -3
  215. package/jest.config.js +15 -0
  216. package/package.json +33 -5
  217. package/src/Messaging.ts +287 -32
  218. package/src/index.ts +3 -3
  219. package/src/models/ContentCard.ts +52 -27
  220. package/src/models/HTMLProposition.ts +1 -1
  221. package/src/models/JSONProposition.ts +1 -1
  222. package/src/models/PersonalizationSchema.ts +1 -0
  223. package/src/models/index.ts +22 -0
  224. package/src/ui/components/Button/Button.spec.tsx +496 -0
  225. package/src/ui/components/Button/Button.tsx +76 -0
  226. package/src/ui/components/ContentCardView/ContentCardView.spec.tsx +278 -0
  227. package/src/ui/components/ContentCardView/ContentCardView.tsx +400 -0
  228. package/src/ui/components/DismissButton/DismissButton.spec.tsx +314 -0
  229. package/src/ui/components/DismissButton/DismissButton.tsx +100 -0
  230. package/src/ui/components/FullScreenCenterView/FullScreenCenterView.tsx +32 -0
  231. package/src/ui/components/Inbox/EmptyState.tsx +89 -0
  232. package/src/ui/components/Inbox/Inbox.spec.tsx +478 -0
  233. package/src/ui/components/Inbox/Inbox.tsx +275 -0
  234. package/src/ui/components/Pagination/Pagination.spec.tsx +159 -0
  235. package/src/ui/components/Pagination/Pagination.tsx +222 -0
  236. package/src/ui/components/UnreadIcon/UnreadIcon.spec.tsx +878 -0
  237. package/src/ui/components/UnreadIcon/UnreadIcon.tsx +234 -0
  238. package/src/ui/components/index.ts +22 -0
  239. package/{dist/models/MessagingPropositionItem.js → src/ui/hooks/index.ts} +5 -4
  240. package/src/ui/hooks/useAspectRatio.spec.tsx +66 -0
  241. package/src/ui/hooks/useAspectRatio.tsx +39 -0
  242. package/src/ui/hooks/useContentCardUI.spec.tsx +82 -0
  243. package/src/ui/hooks/useContentCardUI.ts +48 -0
  244. package/src/ui/hooks/useInbox.spec.tsx +87 -0
  245. package/src/ui/hooks/useInbox.ts +46 -0
  246. package/src/ui/hooks/useInboxSettings.spec.tsx +41 -0
  247. package/src/ui/hooks/useInboxSettings.ts +24 -0
  248. package/src/ui/index.ts +7 -0
  249. package/src/ui/providers/InboxProvider.tsx +79 -0
  250. package/src/ui/theme/Theme.ts +57 -0
  251. package/src/ui/theme/ThemeProvider.tsx +120 -0
  252. package/src/ui/theme/index.ts +14 -0
  253. package/src/ui/types/ContentViewEvent.ts +20 -0
  254. package/src/ui/types/Templates.ts +77 -0
  255. package/src/ui/types/index.ts +14 -0
  256. package/src/ui/utils/generateCardHash.spec.tsx +86 -0
  257. package/src/ui/utils/generateCardHash.ts +59 -0
  258. package/src/ui/utils/inboxStorage.spec.tsx +136 -0
  259. package/src/ui/utils/inboxStorage.ts +64 -0
  260. package/src/ui/utils/index.ts +3 -0
  261. package/tutorials/ContentCardCustomizationGuide.md +661 -0
  262. package/tutorials/ContentCards.md +419 -0
  263. package/tutorials/Inbox.md +515 -0
  264. package/tutorials/resources/image-only-template.png +0 -0
  265. package/tutorials/resources/large-image-template.png +0 -0
  266. package/tutorials/resources/small-image-template.png +0 -0
  267. package/dist/Messaging.js +0 -152
  268. package/dist/Messaging.js.map +0 -1
  269. package/dist/index.js +0 -34
  270. package/dist/index.js.map +0 -1
  271. package/dist/models/ContentCard.d.ts +0 -51
  272. package/dist/models/ContentCard.js.map +0 -1
  273. package/dist/models/HTMLProposition.js.map +0 -1
  274. package/dist/models/InAppMessage.js.map +0 -1
  275. package/dist/models/JSONProposition.js.map +0 -1
  276. package/dist/models/Message.js +0 -156
  277. package/dist/models/Message.js.map +0 -1
  278. package/dist/models/MessagingDelegate.js +0 -14
  279. package/dist/models/MessagingDelegate.js.map +0 -1
  280. package/dist/models/MessagingEdgeEventType.js +0 -24
  281. package/dist/models/MessagingEdgeEventType.js.map +0 -1
  282. package/dist/models/MessagingProposition.js +0 -59
  283. package/dist/models/MessagingProposition.js.map +0 -1
  284. package/dist/models/MessagingPropositionItem.js.map +0 -1
  285. package/dist/models/PersonalizationSchema.js +0 -25
  286. package/dist/models/PersonalizationSchema.js.map +0 -1
  287. package/dist/models/PropositionItem.js +0 -78
  288. package/dist/models/PropositionItem.js.map +0 -1
  289. package/dist/models/ScopeDetails.js.map +0 -1
@@ -0,0 +1,815 @@
1
+ "use strict";
2
+
3
+ /*
4
+ Copyright 2026 Adobe. All rights reserved.
5
+ This file is licensed to you under the Apache License, Version 2.0 (the
6
+ "License"); you may not use this file except in compliance with the License.
7
+ You may obtain a copy of the License at
8
+ http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law
9
+ or agreed to in writing, software distributed under the License is
10
+ distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF
11
+ ANY KIND, either express or implied. See the License for the specific
12
+ language governing permissions and limitations under the License.
13
+ */
14
+ import { act, render, waitFor } from '@testing-library/react-native';
15
+ import React from 'react';
16
+ import { Image, useColorScheme } from 'react-native';
17
+ import InboxProvider from "../../providers/InboxProvider.js";
18
+ import UnreadIcon from "./UnreadIcon.js";
19
+
20
+ // Mock useColorScheme
21
+ jest.mock('react-native/Libraries/Utilities/useColorScheme');
22
+ const mockUseColorScheme = useColorScheme;
23
+ describe('UnreadIcon', () => {
24
+ const mockInboxSettings = {
25
+ content: {
26
+ heading: {
27
+ content: 'Test'
28
+ },
29
+ layout: {
30
+ orientation: 'vertical'
31
+ },
32
+ capacity: 10,
33
+ emptyStateSettings: {
34
+ message: {
35
+ content: 'Empty'
36
+ }
37
+ },
38
+ unread_indicator: {
39
+ unread_bg: {
40
+ clr: {
41
+ light: '#FFF3E0',
42
+ dark: '#2D1B0E'
43
+ }
44
+ },
45
+ unread_icon: {
46
+ placement: 'topright',
47
+ image: {
48
+ url: 'https://example.com/icon.png',
49
+ darkUrl: ''
50
+ }
51
+ }
52
+ },
53
+ isUnreadEnabled: true
54
+ },
55
+ showPagination: false
56
+ };
57
+ beforeEach(() => {
58
+ jest.clearAllMocks();
59
+ mockUseColorScheme.mockReturnValue('light');
60
+ });
61
+ afterEach(() => {
62
+ jest.clearAllMocks();
63
+ });
64
+ describe('Basic rendering', () => {
65
+ it('should render successfully with inbox settings', () => {
66
+ const {
67
+ getByTestId
68
+ } = render(/*#__PURE__*/React.createElement(InboxProvider, {
69
+ settings: mockInboxSettings
70
+ }, /*#__PURE__*/React.createElement(UnreadIcon, {
71
+ testID: "unread-icon"
72
+ })));
73
+ expect(getByTestId('unread-icon')).toBeTruthy();
74
+ });
75
+ it('should render with custom size', () => {
76
+ const {
77
+ getByTestId
78
+ } = render(/*#__PURE__*/React.createElement(InboxProvider, {
79
+ settings: mockInboxSettings
80
+ }, /*#__PURE__*/React.createElement(UnreadIcon, {
81
+ testID: "unread-icon",
82
+ size: 30
83
+ })));
84
+ expect(getByTestId('unread-icon')).toBeTruthy();
85
+ });
86
+ it('should render without crashing when settings provide null', () => {
87
+ expect(() => {
88
+ render(/*#__PURE__*/React.createElement(InboxProvider, {
89
+ settings: null
90
+ }, /*#__PURE__*/React.createElement(UnreadIcon, {
91
+ type: "dot"
92
+ })));
93
+ }).not.toThrow();
94
+ });
95
+ });
96
+ describe('Placement positions', () => {
97
+ it('should render with topright placement', () => {
98
+ expect(() => {
99
+ render(/*#__PURE__*/React.createElement(InboxProvider, {
100
+ settings: mockInboxSettings
101
+ }, /*#__PURE__*/React.createElement(UnreadIcon, null)));
102
+ }).not.toThrow();
103
+ });
104
+ it('should render with topleft placement', () => {
105
+ const settings = {
106
+ ...mockInboxSettings,
107
+ content: {
108
+ ...mockInboxSettings.content,
109
+ unread_indicator: {
110
+ ...mockInboxSettings.content.unread_indicator,
111
+ unread_icon: {
112
+ ...mockInboxSettings.content.unread_indicator.unread_icon,
113
+ placement: 'topleft'
114
+ }
115
+ }
116
+ }
117
+ };
118
+ expect(() => {
119
+ render(/*#__PURE__*/React.createElement(InboxProvider, {
120
+ settings: settings
121
+ }, /*#__PURE__*/React.createElement(UnreadIcon, null)));
122
+ }).not.toThrow();
123
+ });
124
+ it('should render with bottomright placement', () => {
125
+ const settings = {
126
+ ...mockInboxSettings,
127
+ content: {
128
+ ...mockInboxSettings.content,
129
+ unread_indicator: {
130
+ ...mockInboxSettings.content.unread_indicator,
131
+ unread_icon: {
132
+ ...mockInboxSettings.content.unread_indicator.unread_icon,
133
+ placement: 'bottomright'
134
+ }
135
+ }
136
+ }
137
+ };
138
+ expect(() => {
139
+ render(/*#__PURE__*/React.createElement(InboxProvider, {
140
+ settings: settings
141
+ }, /*#__PURE__*/React.createElement(UnreadIcon, null)));
142
+ }).not.toThrow();
143
+ });
144
+ it('should render with bottomleft placement', () => {
145
+ const settings = {
146
+ ...mockInboxSettings,
147
+ content: {
148
+ ...mockInboxSettings.content,
149
+ unread_indicator: {
150
+ ...mockInboxSettings.content.unread_indicator,
151
+ unread_icon: {
152
+ ...mockInboxSettings.content.unread_indicator.unread_icon,
153
+ placement: 'bottomleft'
154
+ }
155
+ }
156
+ }
157
+ };
158
+ expect(() => {
159
+ render(/*#__PURE__*/React.createElement(InboxProvider, {
160
+ settings: settings
161
+ }, /*#__PURE__*/React.createElement(UnreadIcon, null)));
162
+ }).not.toThrow();
163
+ });
164
+ it('falls back to topright when props.position is unknown and no context placement', () => {
165
+ const settingsWithoutIndicator = {
166
+ ...mockInboxSettings,
167
+ content: {
168
+ ...mockInboxSettings.content,
169
+ unread_indicator: undefined
170
+ }
171
+ };
172
+ const {
173
+ getByTestId
174
+ } = render(/*#__PURE__*/React.createElement(InboxProvider, {
175
+ settings: settingsWithoutIndicator
176
+ }, /*#__PURE__*/React.createElement(UnreadIcon, {
177
+ testID: "unread-icon",
178
+ position: 'unknown'
179
+ })));
180
+ const container = getByTestId('unread-icon');
181
+ const styles = (Array.isArray(container.props.style) ? container.props.style : [container.props.style]).flat(Infinity);
182
+ const hasTopRight = styles.some(s => s && s.top === 6 && s.right === 6);
183
+ expect(hasTopRight).toBe(true);
184
+ });
185
+ it('falls back to topright when context placement is unknown', () => {
186
+ const settingsWithUnknownPlacement = {
187
+ ...mockInboxSettings,
188
+ content: {
189
+ ...mockInboxSettings.content,
190
+ unread_indicator: {
191
+ ...mockInboxSettings.content.unread_indicator,
192
+ unread_icon: {
193
+ placement: 'unknown',
194
+ image: {
195
+ url: ''
196
+ }
197
+ }
198
+ }
199
+ }
200
+ };
201
+ const {
202
+ getByTestId
203
+ } = render(/*#__PURE__*/React.createElement(InboxProvider, {
204
+ settings: settingsWithUnknownPlacement
205
+ }, /*#__PURE__*/React.createElement(UnreadIcon, {
206
+ testID: "unread-icon"
207
+ })));
208
+ const container = getByTestId('unread-icon');
209
+ const styles = (Array.isArray(container.props.style) ? container.props.style : [container.props.style]).flat(Infinity);
210
+ const hasTopRight = styles.some(s => s && s.top === 6 && s.right === 6);
211
+ expect(hasTopRight).toBe(true);
212
+ });
213
+ });
214
+ describe('Light mode rendering', () => {
215
+ beforeEach(() => {
216
+ mockUseColorScheme.mockReturnValue('light');
217
+ });
218
+ it('should render in light mode with image URL', () => {
219
+ expect(() => {
220
+ render(/*#__PURE__*/React.createElement(InboxProvider, {
221
+ settings: mockInboxSettings
222
+ }, /*#__PURE__*/React.createElement(UnreadIcon, null)));
223
+ }).not.toThrow();
224
+ });
225
+ it('should render dot when URL is empty string in light mode', () => {
226
+ const settings = {
227
+ ...mockInboxSettings,
228
+ content: {
229
+ ...mockInboxSettings.content,
230
+ unread_indicator: {
231
+ ...mockInboxSettings.content.unread_indicator,
232
+ unread_icon: {
233
+ ...mockInboxSettings.content.unread_indicator.unread_icon,
234
+ image: {
235
+ url: '',
236
+ darkUrl: ''
237
+ }
238
+ }
239
+ }
240
+ }
241
+ };
242
+ expect(() => {
243
+ render(/*#__PURE__*/React.createElement(InboxProvider, {
244
+ settings: settings
245
+ }, /*#__PURE__*/React.createElement(UnreadIcon, null)));
246
+ }).not.toThrow();
247
+ });
248
+ });
249
+ describe('Dark mode rendering', () => {
250
+ beforeEach(() => {
251
+ mockUseColorScheme.mockReturnValue('dark');
252
+ });
253
+ it('should render in dark mode with darkUrl provided', () => {
254
+ const settings = {
255
+ ...mockInboxSettings,
256
+ content: {
257
+ ...mockInboxSettings.content,
258
+ unread_indicator: {
259
+ ...mockInboxSettings.content.unread_indicator,
260
+ unread_icon: {
261
+ ...mockInboxSettings.content.unread_indicator.unread_icon,
262
+ image: {
263
+ url: 'https://example.com/light.png',
264
+ darkUrl: 'https://example.com/dark.png'
265
+ }
266
+ }
267
+ }
268
+ }
269
+ };
270
+ expect(() => {
271
+ render(/*#__PURE__*/React.createElement(InboxProvider, {
272
+ settings: settings
273
+ }, /*#__PURE__*/React.createElement(UnreadIcon, null)));
274
+ }).not.toThrow();
275
+ });
276
+ it('should render dot when darkUrl is empty string in dark mode', () => {
277
+ expect(() => {
278
+ render(/*#__PURE__*/React.createElement(InboxProvider, {
279
+ settings: mockInboxSettings
280
+ }, /*#__PURE__*/React.createElement(UnreadIcon, null)));
281
+ }).not.toThrow();
282
+ });
283
+ it('should fallback to light mode image when no darkUrl provided', () => {
284
+ const settings = {
285
+ ...mockInboxSettings,
286
+ content: {
287
+ ...mockInboxSettings.content,
288
+ unread_indicator: {
289
+ ...mockInboxSettings.content.unread_indicator,
290
+ unread_icon: {
291
+ placement: 'topright',
292
+ image: {
293
+ url: 'https://example.com/icon.png'
294
+ }
295
+ }
296
+ }
297
+ }
298
+ };
299
+ expect(() => {
300
+ render(/*#__PURE__*/React.createElement(InboxProvider, {
301
+ settings: settings
302
+ }, /*#__PURE__*/React.createElement(UnreadIcon, null)));
303
+ }).not.toThrow();
304
+ });
305
+ });
306
+ describe('Props-based rendering', () => {
307
+ it('should render with custom source prop when no settings provided', () => {
308
+ const settingsWithoutImage = {
309
+ ...mockInboxSettings,
310
+ content: {
311
+ ...mockInboxSettings.content,
312
+ unread_indicator: undefined
313
+ }
314
+ };
315
+ expect(() => {
316
+ render(/*#__PURE__*/React.createElement(InboxProvider, {
317
+ settings: settingsWithoutImage
318
+ }, /*#__PURE__*/React.createElement(UnreadIcon, {
319
+ source: {
320
+ uri: 'https://custom.com/icon.png'
321
+ }
322
+ })));
323
+ }).not.toThrow();
324
+ });
325
+ it('should render with custom darkSource prop', () => {
326
+ mockUseColorScheme.mockReturnValue('dark');
327
+ const settingsWithoutImage = {
328
+ ...mockInboxSettings,
329
+ content: {
330
+ ...mockInboxSettings.content,
331
+ unread_indicator: undefined
332
+ }
333
+ };
334
+ expect(() => {
335
+ render(/*#__PURE__*/React.createElement(InboxProvider, {
336
+ settings: settingsWithoutImage
337
+ }, /*#__PURE__*/React.createElement(UnreadIcon, {
338
+ source: {
339
+ uri: 'https://custom.com/light.png'
340
+ },
341
+ darkSource: {
342
+ uri: 'https://custom.com/dark.png'
343
+ }
344
+ })));
345
+ }).not.toThrow();
346
+ });
347
+ it('should render with custom position prop', () => {
348
+ const settingsWithoutImage = {
349
+ ...mockInboxSettings,
350
+ content: {
351
+ ...mockInboxSettings.content,
352
+ unread_indicator: undefined
353
+ }
354
+ };
355
+ expect(() => {
356
+ render(/*#__PURE__*/React.createElement(InboxProvider, {
357
+ settings: settingsWithoutImage
358
+ }, /*#__PURE__*/React.createElement(UnreadIcon, {
359
+ position: "bottomleft"
360
+ })));
361
+ }).not.toThrow();
362
+ });
363
+ it('should render as dot when type prop is "dot"', () => {
364
+ const settingsWithoutImage = {
365
+ ...mockInboxSettings,
366
+ content: {
367
+ ...mockInboxSettings.content,
368
+ unread_indicator: undefined
369
+ }
370
+ };
371
+ expect(() => {
372
+ render(/*#__PURE__*/React.createElement(InboxProvider, {
373
+ settings: settingsWithoutImage
374
+ }, /*#__PURE__*/React.createElement(UnreadIcon, {
375
+ type: "dot"
376
+ })));
377
+ }).not.toThrow();
378
+ });
379
+ it('should render as image when type prop is "image"', () => {
380
+ const settingsWithoutImage = {
381
+ ...mockInboxSettings,
382
+ content: {
383
+ ...mockInboxSettings.content,
384
+ unread_indicator: undefined
385
+ }
386
+ };
387
+ expect(() => {
388
+ render(/*#__PURE__*/React.createElement(InboxProvider, {
389
+ settings: settingsWithoutImage
390
+ }, /*#__PURE__*/React.createElement(UnreadIcon, {
391
+ type: "image",
392
+ source: {
393
+ uri: 'https://custom.com/icon.png'
394
+ }
395
+ })));
396
+ }).not.toThrow();
397
+ });
398
+ it('renders default dot when no unread_indicator and no image props provided', () => {
399
+ // With no unread_indicator and no source/darkSource props, default content should be a dot (no Image)
400
+ const settingsWithoutIndicator = {
401
+ ...mockInboxSettings,
402
+ content: {
403
+ ...mockInboxSettings.content,
404
+ unread_indicator: undefined
405
+ }
406
+ };
407
+ const {
408
+ UNSAFE_queryByType
409
+ } = render(/*#__PURE__*/React.createElement(InboxProvider, {
410
+ settings: settingsWithoutIndicator
411
+ }, /*#__PURE__*/React.createElement(UnreadIcon, null)));
412
+ expect(UNSAFE_queryByType(Image)).toBeNull();
413
+ });
414
+ });
415
+ describe('Custom styles', () => {
416
+ it('should accept and apply custom imageStyle', () => {
417
+ const customImageStyle = {
418
+ opacity: 0.8
419
+ };
420
+ expect(() => {
421
+ render(/*#__PURE__*/React.createElement(InboxProvider, {
422
+ settings: mockInboxSettings
423
+ }, /*#__PURE__*/React.createElement(UnreadIcon, {
424
+ imageStyle: customImageStyle
425
+ })));
426
+ }).not.toThrow();
427
+ });
428
+ it('should accept and apply custom containerStyle', () => {
429
+ const customContainerStyle = {
430
+ padding: 5
431
+ };
432
+ expect(() => {
433
+ render(/*#__PURE__*/React.createElement(InboxProvider, {
434
+ settings: mockInboxSettings
435
+ }, /*#__PURE__*/React.createElement(UnreadIcon, {
436
+ containerStyle: customContainerStyle
437
+ })));
438
+ }).not.toThrow();
439
+ });
440
+ it('should handle both imageStyle and containerStyle together', () => {
441
+ expect(() => {
442
+ render(/*#__PURE__*/React.createElement(InboxProvider, {
443
+ settings: mockInboxSettings
444
+ }, /*#__PURE__*/React.createElement(UnreadIcon, {
445
+ imageStyle: {
446
+ opacity: 0.8
447
+ },
448
+ containerStyle: {
449
+ padding: 5
450
+ }
451
+ })));
452
+ }).not.toThrow();
453
+ });
454
+ it('renders Image when renderType is image via darkSource prop only (branch: imageSource || darkImageSource)', () => {
455
+ mockUseColorScheme.mockReturnValue('dark');
456
+ const settingsWithoutIndicator = {
457
+ ...mockInboxSettings,
458
+ content: {
459
+ ...mockInboxSettings.content,
460
+ unread_indicator: undefined
461
+ }
462
+ };
463
+ const {
464
+ UNSAFE_getByType
465
+ } = render(/*#__PURE__*/React.createElement(InboxProvider, {
466
+ settings: settingsWithoutIndicator
467
+ }, /*#__PURE__*/React.createElement(UnreadIcon, {
468
+ type: "dot",
469
+ darkSource: {
470
+ uri: 'https://custom.com/dark.png'
471
+ }
472
+ })));
473
+ const imageComponent = UNSAFE_getByType(Image);
474
+ expect(imageComponent.props.source).toEqual({
475
+ uri: 'https://custom.com/dark.png'
476
+ });
477
+ });
478
+ });
479
+ describe('Size variations', () => {
480
+ it('should render with default size of 20', () => {
481
+ expect(() => {
482
+ render(/*#__PURE__*/React.createElement(InboxProvider, {
483
+ settings: mockInboxSettings
484
+ }, /*#__PURE__*/React.createElement(UnreadIcon, null)));
485
+ }).not.toThrow();
486
+ });
487
+ it('should render with custom size of 30', () => {
488
+ expect(() => {
489
+ render(/*#__PURE__*/React.createElement(InboxProvider, {
490
+ settings: mockInboxSettings
491
+ }, /*#__PURE__*/React.createElement(UnreadIcon, {
492
+ size: 30
493
+ })));
494
+ }).not.toThrow();
495
+ });
496
+ it('should render with custom size of 15', () => {
497
+ expect(() => {
498
+ render(/*#__PURE__*/React.createElement(InboxProvider, {
499
+ settings: mockInboxSettings
500
+ }, /*#__PURE__*/React.createElement(UnreadIcon, {
501
+ size: 15
502
+ })));
503
+ }).not.toThrow();
504
+ });
505
+ it('should handle very large size', () => {
506
+ expect(() => {
507
+ render(/*#__PURE__*/React.createElement(InboxProvider, {
508
+ settings: mockInboxSettings
509
+ }, /*#__PURE__*/React.createElement(UnreadIcon, {
510
+ size: 100
511
+ })));
512
+ }).not.toThrow();
513
+ });
514
+ it('should handle very small size', () => {
515
+ expect(() => {
516
+ render(/*#__PURE__*/React.createElement(InboxProvider, {
517
+ settings: mockInboxSettings
518
+ }, /*#__PURE__*/React.createElement(UnreadIcon, {
519
+ size: 5
520
+ })));
521
+ }).not.toThrow();
522
+ });
523
+ });
524
+ describe('Context settings priority', () => {
525
+ it('should prioritize context settings over props', () => {
526
+ expect(() => {
527
+ render(/*#__PURE__*/React.createElement(InboxProvider, {
528
+ settings: mockInboxSettings
529
+ }, /*#__PURE__*/React.createElement(UnreadIcon, {
530
+ position: "bottomleft"
531
+ })));
532
+ }).not.toThrow();
533
+ });
534
+ it('should use props when context settings are not available', () => {
535
+ const settingsWithoutImage = {
536
+ ...mockInboxSettings,
537
+ content: {
538
+ ...mockInboxSettings.content,
539
+ unread_indicator: undefined
540
+ }
541
+ };
542
+ expect(() => {
543
+ render(/*#__PURE__*/React.createElement(InboxProvider, {
544
+ settings: settingsWithoutImage
545
+ }, /*#__PURE__*/React.createElement(UnreadIcon, {
546
+ position: "bottomleft",
547
+ source: {
548
+ uri: 'https://custom.com/icon.png'
549
+ }
550
+ })));
551
+ }).not.toThrow();
552
+ });
553
+ });
554
+ describe('Image error handling', () => {
555
+ it('should render without crashing when image URL is invalid', () => {
556
+ const settings = {
557
+ ...mockInboxSettings,
558
+ content: {
559
+ ...mockInboxSettings.content,
560
+ unread_indicator: {
561
+ ...mockInboxSettings.content.unread_indicator,
562
+ unread_icon: {
563
+ ...mockInboxSettings.content.unread_indicator.unread_icon,
564
+ image: {
565
+ url: 'invalid-url',
566
+ darkUrl: ''
567
+ }
568
+ }
569
+ }
570
+ }
571
+ };
572
+ expect(() => {
573
+ render(/*#__PURE__*/React.createElement(InboxProvider, {
574
+ settings: settings
575
+ }, /*#__PURE__*/React.createElement(UnreadIcon, null)));
576
+ }).not.toThrow();
577
+ });
578
+ it('renders dot when image load fails (onError branch)', async () => {
579
+ const settings = {
580
+ ...mockInboxSettings,
581
+ content: {
582
+ ...mockInboxSettings.content,
583
+ unread_indicator: {
584
+ ...mockInboxSettings.content.unread_indicator,
585
+ unread_icon: {
586
+ ...mockInboxSettings.content.unread_indicator.unread_icon,
587
+ image: {
588
+ url: 'https://example.com/icon.png',
589
+ darkUrl: ''
590
+ }
591
+ }
592
+ }
593
+ }
594
+ };
595
+ const warnSpy = jest.spyOn(console, 'warn').mockImplementation(() => {});
596
+ const {
597
+ UNSAFE_getByType
598
+ } = render(/*#__PURE__*/React.createElement(InboxProvider, {
599
+ settings: settings
600
+ }, /*#__PURE__*/React.createElement(UnreadIcon, {
601
+ testID: "unread-icon"
602
+ })));
603
+ const image = UNSAFE_getByType(Image);
604
+ await act(async () => {
605
+ image.props.onError({
606
+ nativeEvent: {
607
+ error: 'failed'
608
+ }
609
+ });
610
+ });
611
+ await waitFor(() => {
612
+ expect(warnSpy).toHaveBeenCalledWith('Failed to load unread icon image:', 'failed');
613
+ });
614
+ warnSpy.mockRestore();
615
+ });
616
+ });
617
+ describe('Edge cases', () => {
618
+ it('should handle undefined image URLs', () => {
619
+ const settings = {
620
+ ...mockInboxSettings,
621
+ content: {
622
+ ...mockInboxSettings.content,
623
+ unread_indicator: {
624
+ ...mockInboxSettings.content.unread_indicator,
625
+ unread_icon: {
626
+ placement: 'topright',
627
+ image: {
628
+ url: undefined,
629
+ darkUrl: undefined
630
+ }
631
+ }
632
+ }
633
+ }
634
+ };
635
+ expect(() => {
636
+ render(/*#__PURE__*/React.createElement(InboxProvider, {
637
+ settings: settings
638
+ }, /*#__PURE__*/React.createElement(UnreadIcon, null)));
639
+ }).not.toThrow();
640
+ });
641
+ it('should handle zero size', () => {
642
+ expect(() => {
643
+ render(/*#__PURE__*/React.createElement(InboxProvider, {
644
+ settings: mockInboxSettings
645
+ }, /*#__PURE__*/React.createElement(UnreadIcon, {
646
+ size: 0
647
+ })));
648
+ }).not.toThrow();
649
+ });
650
+ it('should handle negative size', () => {
651
+ expect(() => {
652
+ render(/*#__PURE__*/React.createElement(InboxProvider, {
653
+ settings: mockInboxSettings
654
+ }, /*#__PURE__*/React.createElement(UnreadIcon, {
655
+ size: -10
656
+ })));
657
+ }).not.toThrow();
658
+ });
659
+ });
660
+ describe('Color scheme switching', () => {
661
+ it('should adapt to color scheme changes from light to dark', () => {
662
+ mockUseColorScheme.mockReturnValue('light');
663
+ const {
664
+ rerender
665
+ } = render(/*#__PURE__*/React.createElement(InboxProvider, {
666
+ settings: mockInboxSettings
667
+ }, /*#__PURE__*/React.createElement(UnreadIcon, null)));
668
+
669
+ // Switch to dark mode
670
+ mockUseColorScheme.mockReturnValue('dark');
671
+ expect(() => {
672
+ rerender(/*#__PURE__*/React.createElement(InboxProvider, {
673
+ settings: mockInboxSettings
674
+ }, /*#__PURE__*/React.createElement(UnreadIcon, null)));
675
+ }).not.toThrow();
676
+ });
677
+ it('should handle null color scheme', () => {
678
+ mockUseColorScheme.mockReturnValue(null);
679
+ expect(() => {
680
+ render(/*#__PURE__*/React.createElement(InboxProvider, {
681
+ settings: mockInboxSettings
682
+ }, /*#__PURE__*/React.createElement(UnreadIcon, null)));
683
+ }).not.toThrow();
684
+ });
685
+ });
686
+ describe('Behavioral verification', () => {
687
+ it('should render an Image when valid URL is provided', () => {
688
+ const {
689
+ UNSAFE_getByType
690
+ } = render(/*#__PURE__*/React.createElement(InboxProvider, {
691
+ settings: mockInboxSettings
692
+ }, /*#__PURE__*/React.createElement(UnreadIcon, null)));
693
+
694
+ // Should render an Image component when URL is provided
695
+ expect(() => UNSAFE_getByType(Image)).not.toThrow();
696
+ });
697
+ it('should render dot when image URLs are empty', () => {
698
+ const settings = {
699
+ ...mockInboxSettings,
700
+ content: {
701
+ ...mockInboxSettings.content,
702
+ unread_indicator: {
703
+ ...mockInboxSettings.content.unread_indicator,
704
+ unread_icon: {
705
+ ...mockInboxSettings.content.unread_indicator.unread_icon,
706
+ image: {
707
+ url: '',
708
+ darkUrl: ''
709
+ }
710
+ }
711
+ }
712
+ }
713
+ };
714
+ const {
715
+ UNSAFE_queryByType
716
+ } = render(/*#__PURE__*/React.createElement(InboxProvider, {
717
+ settings: settings
718
+ }, /*#__PURE__*/React.createElement(UnreadIcon, null)));
719
+
720
+ // Should not render Image when URLs are empty
721
+ expect(UNSAFE_queryByType(Image)).toBeNull();
722
+ });
723
+ it('should render image when source is provided even with type="dot"', () => {
724
+ const settingsWithoutImage = {
725
+ ...mockInboxSettings,
726
+ content: {
727
+ ...mockInboxSettings.content,
728
+ unread_indicator: undefined
729
+ }
730
+ };
731
+ const {
732
+ UNSAFE_getByType
733
+ } = render(/*#__PURE__*/React.createElement(InboxProvider, {
734
+ settings: settingsWithoutImage
735
+ }, /*#__PURE__*/React.createElement(UnreadIcon, {
736
+ type: "dot",
737
+ source: {
738
+ uri: 'https://example.com/icon.png'
739
+ }
740
+ })));
741
+
742
+ // Should render Image when source is provided, even if type is "dot"
743
+ // The presence of source overrides the type prop
744
+ expect(() => UNSAFE_getByType(Image)).not.toThrow();
745
+ });
746
+ it('should use darkUrl in dark mode when provided', () => {
747
+ mockUseColorScheme.mockReturnValue('dark');
748
+ const settings = {
749
+ ...mockInboxSettings,
750
+ content: {
751
+ ...mockInboxSettings.content,
752
+ unread_indicator: {
753
+ ...mockInboxSettings.content.unread_indicator,
754
+ unread_icon: {
755
+ placement: 'topright',
756
+ image: {
757
+ url: 'https://example.com/light.png',
758
+ darkUrl: 'https://example.com/dark.png'
759
+ }
760
+ }
761
+ }
762
+ }
763
+ };
764
+ const {
765
+ UNSAFE_getByType
766
+ } = render(/*#__PURE__*/React.createElement(InboxProvider, {
767
+ settings: settings
768
+ }, /*#__PURE__*/React.createElement(UnreadIcon, null)));
769
+ const imageComponent = UNSAFE_getByType(Image);
770
+ expect(imageComponent.props.source).toEqual({
771
+ uri: 'https://example.com/dark.png'
772
+ });
773
+ });
774
+ it('should fallback to light URL when no darkUrl in dark mode', () => {
775
+ mockUseColorScheme.mockReturnValue('dark');
776
+ const settings = {
777
+ ...mockInboxSettings,
778
+ content: {
779
+ ...mockInboxSettings.content,
780
+ unread_indicator: {
781
+ ...mockInboxSettings.content.unread_indicator,
782
+ unread_icon: {
783
+ placement: 'topright',
784
+ image: {
785
+ url: 'https://example.com/light.png'
786
+ }
787
+ }
788
+ }
789
+ }
790
+ };
791
+ const {
792
+ UNSAFE_getByType
793
+ } = render(/*#__PURE__*/React.createElement(InboxProvider, {
794
+ settings: settings
795
+ }, /*#__PURE__*/React.createElement(UnreadIcon, null)));
796
+ const imageComponent = UNSAFE_getByType(Image);
797
+ expect(imageComponent.props.source).toEqual({
798
+ uri: 'https://example.com/light.png'
799
+ });
800
+ });
801
+ it('should use light URL in light mode', () => {
802
+ mockUseColorScheme.mockReturnValue('light');
803
+ const {
804
+ UNSAFE_getByType
805
+ } = render(/*#__PURE__*/React.createElement(InboxProvider, {
806
+ settings: mockInboxSettings
807
+ }, /*#__PURE__*/React.createElement(UnreadIcon, null)));
808
+ const imageComponent = UNSAFE_getByType(Image);
809
+ expect(imageComponent.props.source).toEqual({
810
+ uri: 'https://example.com/icon.png'
811
+ });
812
+ });
813
+ });
814
+ });
815
+ //# sourceMappingURL=UnreadIcon.spec.js.map