@react-native-firebase/app 26.4.0 → 27.0.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 (242) hide show
  1. package/CHANGELOG.md +48 -0
  2. package/README.md +10 -27
  3. package/RNFBApp.podspec +13 -5
  4. package/android/build.gradle +3 -0
  5. package/android/src/main/java/io/invertase/firebase/common/RNFBHandleCollisionException.kt +29 -0
  6. package/android/src/main/java/io/invertase/firebase/common/RNFBHandleMap.kt +146 -0
  7. package/android/src/main/java/io/invertase/firebase/common/TaskExecutorService.kt +156 -0
  8. package/android/src/main/java/io/invertase/firebase/common/UniversalFirebaseModule.kt +44 -0
  9. package/android/src/main/java/io/invertase/firebase/common/UniversalFirebasePreferences.kt +100 -0
  10. package/android/src/reactnative/java/io/invertase/firebase/app/NativeRNFBTurboApp.kt +250 -0
  11. package/android/src/reactnative/java/io/invertase/firebase/app/ReactNativeFirebaseApp.kt +64 -0
  12. package/android/src/reactnative/java/io/invertase/firebase/app/{ReactNativeFirebaseAppInitProvider.java → ReactNativeFirebaseAppInitProvider.kt} +3 -4
  13. package/android/src/reactnative/java/io/invertase/firebase/app/ReactNativeFirebaseAppPackage.kt +47 -0
  14. package/android/src/reactnative/java/io/invertase/firebase/app/ReactNativeFirebaseAppRegistrar.kt +33 -0
  15. package/android/src/reactnative/java/io/invertase/firebase/app/ReactNativeFirebaseVersion.java +1 -1
  16. package/android/src/reactnative/java/io/invertase/firebase/common/RCTConvertFirebase.kt +185 -0
  17. package/android/src/reactnative/java/io/invertase/firebase/common/ReactNativeFirebaseEvent.kt +35 -0
  18. package/android/src/reactnative/java/io/invertase/firebase/common/ReactNativeFirebaseEventEmitter.kt +662 -0
  19. package/android/src/reactnative/java/io/invertase/firebase/common/ReactNativeFirebaseJSON.kt +103 -0
  20. package/android/src/reactnative/java/io/invertase/firebase/common/ReactNativeFirebaseMeta.kt +96 -0
  21. package/android/src/reactnative/java/io/invertase/firebase/common/ReactNativeFirebaseModule.kt +140 -0
  22. package/android/src/reactnative/java/io/invertase/firebase/common/ReactNativeFirebasePreferences.kt +109 -0
  23. package/android/src/reactnative/java/io/invertase/firebase/common/SharedUtils.kt +451 -0
  24. package/android/src/reactnative/java/io/invertase/firebase/interfaces/{ContextProvider.java → ContextProvider.kt} +8 -8
  25. package/android/src/reactnative/java/io/invertase/firebase/interfaces/{NativeError.java → NativeError.kt} +8 -8
  26. package/android/src/reactnative/java/io/invertase/firebase/interfaces/{NativeEvent.java → NativeEvent.kt} +6 -6
  27. package/android/src/reactnative/java/io/invertase/firebase/utils/NativeRNFBTurboUtils.kt +219 -0
  28. package/android/src/test/java/expo/core/ModuleRegistry.java +9 -0
  29. package/android/src/test/java/io/invertase/firebase/app/NativeRNFBTurboAppTest.java +182 -59
  30. package/android/src/test/java/io/invertase/firebase/app/ReactNativeFirebaseAppComponentsJavaCompatibilityTest.java +70 -0
  31. package/android/src/test/java/io/invertase/firebase/app/ReactNativeFirebaseAppJavaCompatibilityTest.java +60 -0
  32. package/android/src/test/java/io/invertase/firebase/app/ReactNativeFirebaseAppPackageTest.java +165 -0
  33. package/android/src/test/java/io/invertase/firebase/app/ReactNativeFirebaseAppTest.kt +167 -0
  34. package/android/src/test/java/io/invertase/firebase/common/RCTConvertFirebaseJavaCompatibilityTest.java +112 -0
  35. package/android/src/test/java/io/invertase/firebase/common/RCTConvertFirebaseTest.kt +317 -0
  36. package/android/src/test/java/io/invertase/firebase/common/RNFBHandleMapTest.kt +309 -0
  37. package/android/src/test/java/io/invertase/firebase/common/ReactNativeFirebaseEventEmitterJavaCompatibilityTest.java +176 -0
  38. package/android/src/test/java/io/invertase/firebase/common/ReactNativeFirebaseEventEmitterTest.java +143 -12
  39. package/android/src/test/java/io/invertase/firebase/common/ReactNativeFirebaseEventTest.kt +61 -0
  40. package/android/src/test/java/io/invertase/firebase/common/ReactNativeFirebaseJSONJavaCompatibilityTest.java +85 -0
  41. package/android/src/test/java/io/invertase/firebase/common/ReactNativeFirebaseJSONTest.kt +296 -0
  42. package/android/src/test/java/io/invertase/firebase/common/ReactNativeFirebaseMetaJavaCompatibilityTest.java +67 -0
  43. package/android/src/test/java/io/invertase/firebase/common/ReactNativeFirebaseMetaTest.kt +246 -0
  44. package/android/src/test/java/io/invertase/firebase/common/ReactNativeFirebaseModuleTest.kt +254 -0
  45. package/android/src/test/java/io/invertase/firebase/common/ReactNativeFirebasePreferencesJavaCompatibilityTest.java +87 -0
  46. package/android/src/test/java/io/invertase/firebase/common/ReactNativeFirebasePreferencesTest.kt +260 -0
  47. package/android/src/test/java/io/invertase/firebase/common/SharedUtilsJavaCompatibilityTest.java +255 -0
  48. package/android/src/test/java/io/invertase/firebase/common/SharedUtilsTest.kt +674 -0
  49. package/android/src/test/java/io/invertase/firebase/common/TaskExecutorServiceTest.kt +290 -0
  50. package/android/src/test/java/io/invertase/firebase/common/UniversalFirebaseModuleJavaCompatibilityTest.java +178 -0
  51. package/android/src/test/java/io/invertase/firebase/common/UniversalFirebasePreferencesJavaCompatibilityTest.java +99 -0
  52. package/android/src/test/java/io/invertase/firebase/common/UniversalFirebasePreferencesTest.kt +217 -0
  53. package/android/src/test/java/io/invertase/firebase/commoncompat/ReactNativeFirebaseModuleJavaCompatibilityTest.java +176 -0
  54. package/android/src/test/java/io/invertase/firebase/commoncompat/ReactNativeFirebaseModuleKotlinCompatibilityTest.kt +52 -0
  55. package/android/src/test/java/io/invertase/firebase/interfaces/InterfacesJavaCompatibilityTest.java +144 -0
  56. package/android/src/test/java/io/invertase/firebase/interfaces/NativeEventTest.kt +56 -0
  57. package/android/src/test/java/io/invertase/firebase/utils/NativeRNFBTurboUtilsTest.java +517 -21
  58. package/dist/module/FirebaseApp.js +10 -0
  59. package/dist/module/FirebaseApp.js.map +1 -1
  60. package/dist/module/common/deeps.js +3 -0
  61. package/dist/module/common/deeps.js.map +1 -1
  62. package/dist/module/internal/FirebaseModule.js.map +1 -1
  63. package/dist/module/internal/RNFBNativeEventEmitter.js +12 -1
  64. package/dist/module/internal/RNFBNativeEventEmitter.js.map +1 -1
  65. package/dist/module/internal/SharedEventEmitter.js +3 -1
  66. package/dist/module/internal/SharedEventEmitter.js.map +1 -1
  67. package/dist/module/internal/index.js +1 -0
  68. package/dist/module/internal/index.js.map +1 -1
  69. package/dist/module/internal/registry/app.js +7 -1
  70. package/dist/module/internal/registry/app.js.map +1 -1
  71. package/dist/module/types/app.js.map +1 -1
  72. package/dist/module/types/internal.js +2 -0
  73. package/dist/module/version.js +1 -1
  74. package/dist/typescript/lib/FirebaseApp.d.ts +7 -0
  75. package/dist/typescript/lib/FirebaseApp.d.ts.map +1 -1
  76. package/dist/typescript/lib/common/deeps.d.ts.map +1 -1
  77. package/dist/typescript/lib/internal/FirebaseModule.d.ts +2 -3
  78. package/dist/typescript/lib/internal/FirebaseModule.d.ts.map +1 -1
  79. package/dist/typescript/lib/internal/NativeModules.d.ts +4 -1
  80. package/dist/typescript/lib/internal/NativeModules.d.ts.map +1 -1
  81. package/dist/typescript/lib/internal/RNFBNativeEventEmitter.d.ts +2 -2
  82. package/dist/typescript/lib/internal/RNFBNativeEventEmitter.d.ts.map +1 -1
  83. package/dist/typescript/lib/internal/SharedEventEmitter.d.ts +3 -3
  84. package/dist/typescript/lib/internal/SharedEventEmitter.d.ts.map +1 -1
  85. package/dist/typescript/lib/internal/index.d.ts +1 -0
  86. package/dist/typescript/lib/internal/index.d.ts.map +1 -1
  87. package/dist/typescript/lib/internal/registry/app.d.ts.map +1 -1
  88. package/dist/typescript/lib/types/app.d.ts +10 -3
  89. package/dist/typescript/lib/types/app.d.ts.map +1 -1
  90. package/dist/typescript/lib/types/internal.d.ts +12 -0
  91. package/dist/typescript/lib/types/internal.d.ts.map +1 -1
  92. package/dist/typescript/lib/version.d.ts +1 -1
  93. package/firebase-schema.json +4 -0
  94. package/firebase_spm.rb +552 -96
  95. package/ios/RNFBApp/RCTConvert+FIRApp.h +2 -5
  96. package/ios/RNFBApp/RCTConvert+FIRApp.m +11 -6
  97. package/ios/RNFBApp/RCTConvert+FIROptions.h +2 -5
  98. package/ios/RNFBApp/RCTConvert+FIROptions.m +11 -10
  99. package/ios/RNFBApp/RCTConvertFIRApp.swift +86 -0
  100. package/ios/RNFBApp/RCTConvertFIROptions.swift +259 -0
  101. package/ios/RNFBApp/RNFBAppCustomAuthDomains.swift +63 -0
  102. package/ios/RNFBApp/RNFBAppInitializeOptionsMapper.swift +113 -0
  103. package/ios/RNFBApp/RNFBAppLogLevelMapper.swift +53 -0
  104. package/ios/RNFBApp/RNFBAppModule+CustomAuthDomain.m +35 -0
  105. package/ios/RNFBApp/RNFBAppModule.h +6 -2
  106. package/ios/RNFBApp/RNFBAppModule.mm +65 -228
  107. package/ios/RNFBApp/RNFBAppModuleFirebase.swift +439 -0
  108. package/ios/RNFBApp/RNFBAppModuleImplementation.h +68 -0
  109. package/ios/RNFBApp/RNFBAppModuleImplementation.m +195 -0
  110. package/ios/RNFBApp/RNFBHandleMap.m +27 -56
  111. package/ios/RNFBApp/RNFBHandleMapStorage.swift +90 -0
  112. package/ios/RNFBApp/RNFBInitializeAppArguments.swift +82 -0
  113. package/ios/RNFBApp/RNFBJSON.m +22 -38
  114. package/ios/RNFBApp/RNFBJSONImplementation.swift +71 -0
  115. package/ios/RNFBApp/RNFBMeta.m +24 -26
  116. package/ios/RNFBApp/RNFBMetaStorage.swift +76 -0
  117. package/ios/RNFBApp/RNFBNullSentinelDecoding.swift +135 -0
  118. package/ios/RNFBApp/RNFBNullSentinelInterceptor.h +30 -3
  119. package/ios/RNFBApp/RNFBNullSentinelInterceptor.m +28 -5
  120. package/ios/RNFBApp/RNFBPreferences.m +22 -20
  121. package/ios/RNFBApp/RNFBPreferencesStorage.swift +101 -0
  122. package/ios/RNFBApp/RNFBRCTEventEmitter.m +36 -93
  123. package/ios/RNFBApp/RNFBRCTEventEmitterCore.swift +161 -0
  124. package/ios/RNFBApp/RNFBSharedUtils.h +2 -5
  125. package/ios/RNFBApp/RNFBSharedUtils.m +109 -198
  126. package/ios/RNFBApp/RNFBSharedUtilsConfig.swift +72 -0
  127. package/ios/RNFBApp/RNFBSharedUtilsFIRApp.swift +271 -0
  128. package/ios/RNFBApp/RNFBSharedUtilsFormatting.swift +59 -0
  129. package/ios/RNFBApp/RNFBSharedUtilsPromiseRejection.swift +88 -0
  130. package/ios/RNFBApp/RNFBUtilsHelpers.swift +116 -0
  131. package/ios/RNFBApp/RNFBUtilsModule+Foundation.m +44 -0
  132. package/ios/RNFBApp/RNFBUtilsModule+PhotoAssets.m +47 -0
  133. package/ios/RNFBApp/RNFBUtilsModule.h +11 -1
  134. package/ios/RNFBApp/RNFBUtilsModule.mm +10 -85
  135. package/ios/RNFBApp/RNFBUtilsModuleImplementation.h +32 -0
  136. package/ios/RNFBApp/RNFBUtilsModuleImplementation.m +56 -0
  137. package/ios/RNFBApp/RNFBVersion.m +1 -1
  138. package/ios/RNFBApp.xcodeproj/project.pbxproj +100 -0
  139. package/ios/RNFBAppUnitTests/HostStubs/FirebaseCore/FIRApp.m +171 -0
  140. package/ios/RNFBAppUnitTests/HostStubs/FirebaseCore/FirebaseCore.h +78 -0
  141. package/ios/RNFBAppUnitTests/HostStubs/FirebaseInstallations/FIRInstallations.m +7 -0
  142. package/ios/RNFBAppUnitTests/HostStubs/FirebaseInstallations/FirebaseInstallations.h +8 -0
  143. package/ios/RNFBAppUnitTests/HostStubs/RNFBAppModuleHostStub.m +55 -0
  144. package/ios/RNFBAppUnitTests/HostStubs/RNFBAppTurboModules.h +89 -0
  145. package/ios/RNFBAppUnitTests/HostStubs/RNFBAppTurboModules.mm +30 -0
  146. package/ios/RNFBAppUnitTests/HostStubs/React/RCTBridge.h +19 -0
  147. package/ios/RNFBAppUnitTests/HostStubs/React/RCTBridge.m +32 -0
  148. package/ios/RNFBAppUnitTests/HostStubs/React/RCTBridgeModule.h +19 -0
  149. package/ios/RNFBAppUnitTests/HostStubs/React/RCTConvert.h +28 -0
  150. package/ios/RNFBAppUnitTests/HostStubs/React/RCTConvert.m +23 -0
  151. package/ios/RNFBAppUnitTests/HostStubs/React/RCTEventEmitter.h +9 -0
  152. package/ios/RNFBAppUnitTests/HostStubs/React/RCTInvalidating.h +24 -0
  153. package/ios/RNFBAppUnitTests/HostStubs/React/RCTUtils.h +9 -0
  154. package/ios/RNFBAppUnitTests/HostStubs/module.modulemap +13 -0
  155. package/ios/RNFBAppUnitTests/RCTConvertFIRAppFacadeTests.m +61 -0
  156. package/ios/RNFBAppUnitTests/RCTConvertFIRAppTests.swift +73 -0
  157. package/ios/RNFBAppUnitTests/RCTConvertFIROptionsFacadeTests.m +57 -0
  158. package/ios/RNFBAppUnitTests/RCTConvertFIROptionsTests.swift +243 -0
  159. package/ios/RNFBAppUnitTests/RNFBAppCustomAuthDomainsFacadeTests.m +73 -0
  160. package/ios/RNFBAppUnitTests/RNFBAppCustomAuthDomainsTests.swift +70 -0
  161. package/ios/RNFBAppUnitTests/RNFBAppInitializeOptionsMapperTests.swift +190 -0
  162. package/ios/RNFBAppUnitTests/RNFBAppLogLevelFacadeTests.m +76 -0
  163. package/ios/RNFBAppUnitTests/RNFBAppLogLevelMapperTests.swift +59 -0
  164. package/ios/RNFBAppUnitTests/RNFBAppModuleFirebaseFacadeTests.m +215 -0
  165. package/ios/RNFBAppUnitTests/RNFBAppModuleFirebaseTests.swift +430 -0
  166. package/ios/RNFBAppUnitTests/RNFBAppModuleLifecycleTests.m +206 -0
  167. package/ios/RNFBAppUnitTests/RNFBAppModuleShellTests.mm +367 -0
  168. package/ios/RNFBAppUnitTests/RNFBAppUnitTests.xcodeproj/project.pbxproj +355 -2
  169. package/ios/RNFBAppUnitTests/RNFBFirebaseAppClientTests.swift +165 -0
  170. package/ios/RNFBAppUnitTests/RNFBHandleMapStorageTests.swift +121 -0
  171. package/ios/RNFBAppUnitTests/RNFBInitializeAppArgumentsTests.swift +256 -0
  172. package/ios/RNFBAppUnitTests/RNFBJSONImplementationTests.swift +126 -0
  173. package/ios/RNFBAppUnitTests/RNFBJSONTests.m +172 -0
  174. package/ios/RNFBAppUnitTests/RNFBMetaStorageTests.swift +106 -0
  175. package/ios/RNFBAppUnitTests/RNFBMetaTests.m +65 -0
  176. package/ios/RNFBAppUnitTests/RNFBNullSentinelDecodingTests.swift +286 -0
  177. package/ios/RNFBAppUnitTests/RNFBNullSentinelInterceptorTests.m +312 -0
  178. package/ios/RNFBAppUnitTests/RNFBPreferencesStorageTests.swift +105 -0
  179. package/ios/RNFBAppUnitTests/RNFBPreferencesTests.m +110 -0
  180. package/ios/RNFBAppUnitTests/RNFBRCTEventEmitterCoreTests.swift +163 -0
  181. package/ios/RNFBAppUnitTests/RNFBRCTEventEmitterFacadeTests.m +141 -0
  182. package/ios/RNFBAppUnitTests/RNFBSharedUtilsConfigFacadeTests.m +100 -0
  183. package/ios/RNFBAppUnitTests/RNFBSharedUtilsConfigTests.swift +234 -0
  184. package/ios/RNFBAppUnitTests/RNFBSharedUtilsFIRAppFacadeTests.m +145 -0
  185. package/ios/RNFBAppUnitTests/RNFBSharedUtilsFIRAppTests.swift +173 -0
  186. package/ios/RNFBAppUnitTests/RNFBSharedUtilsFormattingFacadeTests.m +38 -0
  187. package/ios/RNFBAppUnitTests/RNFBSharedUtilsFormattingTests.swift +82 -0
  188. package/ios/RNFBAppUnitTests/RNFBSharedUtilsNullSentinelTests.m +35 -0
  189. package/ios/RNFBAppUnitTests/RNFBSharedUtilsPromiseRejectionFacadeTests.m +107 -0
  190. package/ios/RNFBAppUnitTests/RNFBSharedUtilsPromiseRejectionTests.swift +133 -0
  191. package/ios/RNFBAppUnitTests/RNFBUtilsHelpersTests.swift +144 -0
  192. package/ios/RNFBAppUnitTests/RNFBUtilsModuleFacadeTests.m +72 -0
  193. package/ios/RNFBAppUnitTests/RNFBUtilsModuleShellTests.mm +282 -0
  194. package/ios/RNFBFirebase/Package.swift +53 -0
  195. package/ios/RNFBFirebase/Sources/RNFBFirebase/RNFBFirebase.swift +285 -0
  196. package/ios/RNFBFirebase/Sources/RNFBFirebaseBridge/Public/.gitkeep +0 -0
  197. package/ios/RNFBFirebase/Sources/RNFBFirebaseBridge/RNFBFirebaseBridge.m +169 -0
  198. package/ios/RNFBFirebase/Sources/RNFBFirebaseBridge/include/RNFBFirebaseBridge.h +52 -0
  199. package/ios/RNFBFirebaseUnitTests/RNFBAppDynamicFacadeTests.swift +240 -0
  200. package/{android/src/main/java/io/invertase/firebase/common/RNFBHandleCollisionException.java → ios/RNFBFirebaseUnitTests/RNFBFirebaseClientImport.swift} +23 -14
  201. package/ios/RNFBFirebaseUnitTests/RNFBFirebaseUnitTests.xcodeproj/project.pbxproj +588 -0
  202. package/ios/RNFBFirebaseUnitTests/RNFBFirebaseUnitTests.xcodeproj/xcshareddata/xcschemes/RNFBFirebaseUnitTests.xcscheme +83 -0
  203. package/ios_config.sh +50 -22
  204. package/lib/FirebaseApp.ts +10 -0
  205. package/lib/common/deeps.ts +3 -0
  206. package/lib/internal/FirebaseModule.ts +6 -3
  207. package/lib/internal/NativeModules.ts +4 -1
  208. package/lib/internal/RNFBNativeEventEmitter.ts +14 -5
  209. package/lib/internal/SharedEventEmitter.ts +5 -1
  210. package/lib/internal/index.ts +1 -0
  211. package/lib/internal/react-native-vendor-emitter.d.ts +11 -0
  212. package/lib/internal/registry/app.ts +7 -1
  213. package/lib/types/app.ts +10 -3
  214. package/lib/types/internal.ts +19 -0
  215. package/lib/version.ts +1 -1
  216. package/package.json +8 -8
  217. package/plugin/build/ios/appDelegate.js +2 -2
  218. package/plugin/build/ios/podfile.js +16 -16
  219. package/plugin/build/pluginConfig.d.ts +4 -2
  220. package/plugin/src/ios/appDelegate.ts +2 -2
  221. package/plugin/src/ios/podfile.ts +20 -23
  222. package/plugin/src/pluginConfig.ts +4 -2
  223. package/android/src/main/java/io/invertase/firebase/common/RNFBHandleMap.java +0 -150
  224. package/android/src/main/java/io/invertase/firebase/common/TaskExecutorService.java +0 -148
  225. package/android/src/main/java/io/invertase/firebase/common/UniversalFirebaseModule.java +0 -62
  226. package/android/src/main/java/io/invertase/firebase/common/UniversalFirebasePreferences.java +0 -91
  227. package/android/src/reactnative/java/io/invertase/firebase/app/NativeRNFBTurboApp.java +0 -224
  228. package/android/src/reactnative/java/io/invertase/firebase/app/ReactNativeFirebaseApp.java +0 -46
  229. package/android/src/reactnative/java/io/invertase/firebase/app/ReactNativeFirebaseAppPackage.java +0 -49
  230. package/android/src/reactnative/java/io/invertase/firebase/app/ReactNativeFirebaseAppRegistrar.java +0 -35
  231. package/android/src/reactnative/java/io/invertase/firebase/common/RCTConvertFirebase.java +0 -192
  232. package/android/src/reactnative/java/io/invertase/firebase/common/ReactNativeFirebaseEvent.java +0 -53
  233. package/android/src/reactnative/java/io/invertase/firebase/common/ReactNativeFirebaseEventEmitter.java +0 -606
  234. package/android/src/reactnative/java/io/invertase/firebase/common/ReactNativeFirebaseJSON.java +0 -109
  235. package/android/src/reactnative/java/io/invertase/firebase/common/ReactNativeFirebaseMeta.java +0 -101
  236. package/android/src/reactnative/java/io/invertase/firebase/common/ReactNativeFirebaseModule.java +0 -146
  237. package/android/src/reactnative/java/io/invertase/firebase/common/ReactNativeFirebasePreferences.java +0 -96
  238. package/android/src/reactnative/java/io/invertase/firebase/common/SharedUtils.java +0 -441
  239. package/android/src/reactnative/java/io/invertase/firebase/utils/NativeRNFBTurboUtils.java +0 -223
  240. package/android/src/test/java/io/invertase/firebase/common/RNFBHandleMapTest.java +0 -275
  241. package/android/src/test/java/io/invertase/firebase/common/ReactNativeFirebaseJSONTest.java +0 -108
  242. package/android/src/test/java/io/invertase/firebase/common/TaskExecutorServiceTest.java +0 -97
@@ -0,0 +1,141 @@
1
+ /**
2
+ * Copyright (c) 2016-present Invertase Limited & Contributors
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this library except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ #import <XCTest/XCTest.h>
18
+
19
+ #import <React/RCTBridge.h>
20
+ #import "RNFBHandleMapStorage-Swift.inc"
21
+ #import "RNFBRCTEventEmitter.h"
22
+
23
+ @interface RNFBRCTEventEmitterFacadeTests : XCTestCase
24
+ @property(nonatomic, strong) RNFBRCTEventEmitter *emitter;
25
+ @property(nonatomic, strong) RCTBridge *bridge;
26
+ @end
27
+
28
+ @implementation RNFBRCTEventEmitterFacadeTests
29
+
30
+ - (void)setUp {
31
+ [super setUp];
32
+ self.emitter = [[RNFBRCTEventEmitter alloc] init];
33
+ self.bridge = [[RCTBridge alloc] init];
34
+ [self.emitter invalidate];
35
+ }
36
+
37
+ - (void)tearDown {
38
+ [self.emitter invalidate];
39
+ self.emitter.bridge = nil;
40
+ self.emitter = nil;
41
+ self.bridge = nil;
42
+ [super tearDown];
43
+ }
44
+
45
+ - (void)testSharedIsSingleton {
46
+ XCTAssertIdentical([RNFBRCTEventEmitter shared], [RNFBRCTEventEmitter shared]);
47
+ }
48
+
49
+ - (void)testPublicSelectorsUnchanged {
50
+ NSArray<NSString *> *selectorNames = @[
51
+ @"invalidate",
52
+ @"addListener:",
53
+ @"removeListeners:all:",
54
+ @"sendEventWithName:body:",
55
+ @"notifyJsReady:",
56
+ @"getListenersDictionary",
57
+ ];
58
+ for (NSString *selectorName in selectorNames) {
59
+ XCTAssertTrue([self.emitter respondsToSelector:NSSelectorFromString(selectorName)]);
60
+ }
61
+ XCTAssertTrue([RNFBRCTEventEmitter respondsToSelector:@selector(shared)]);
62
+ XCTAssertTrue([self.emitter respondsToSelector:@selector(bridge)]);
63
+ XCTAssertTrue([self.emitter respondsToSelector:@selector(setBridge:)]);
64
+ }
65
+
66
+ - (void)testInvalidateResetsListenersAndQueue {
67
+ [self.emitter sendEventWithName:@"evt" body:@{@"a" : @1}];
68
+ [self.emitter addListener:@"evt"];
69
+ [self.emitter notifyJsReady:YES];
70
+
71
+ [self.emitter invalidate];
72
+
73
+ NSDictionary *dict = [self.emitter getListenersDictionary];
74
+ XCTAssertEqualObjects(dict[@"listeners"], @0);
75
+ XCTAssertEqualObjects(dict[@"queued"], @0);
76
+ XCTAssertEqual([dict[@"events"] count], 0u);
77
+ }
78
+
79
+ - (void)testSendEventQueuesWithoutBridge {
80
+ [self.emitter notifyJsReady:YES];
81
+ [self.emitter addListener:@"evt"];
82
+ [self.emitter sendEventWithName:@"evt" body:@{@"a" : @1}];
83
+
84
+ NSDictionary *dict = [self.emitter getListenersDictionary];
85
+ XCTAssertEqualObjects(dict[@"queued"], @1);
86
+ XCTAssertNil(self.bridge.lastModule);
87
+ }
88
+
89
+ - (void)testSendEventEmitsViaBridgeWhenReady {
90
+ self.emitter.bridge = self.bridge;
91
+ [self.emitter notifyJsReady:YES];
92
+ [self.emitter addListener:@"evt"];
93
+ [self.bridge resetLastJSCallForTesting];
94
+
95
+ [self.emitter sendEventWithName:@"evt" body:@{@"a" : @1}];
96
+
97
+ XCTAssertEqualObjects(self.bridge.lastModule, @"RCTDeviceEventEmitter");
98
+ XCTAssertEqualObjects(self.bridge.lastMethod, @"emit");
99
+ XCTAssertEqualObjects(self.bridge.lastArgs[0], @"rnfb_evt");
100
+ XCTAssertEqualObjects(self.bridge.lastArgs[1][@"a"], @1);
101
+ XCTAssertEqualObjects([self.emitter getListenersDictionary][@"queued"], @0);
102
+ }
103
+
104
+ - (void)testSendEventEmitsNilBodyAsSingleArg {
105
+ self.emitter.bridge = self.bridge;
106
+ [self.emitter notifyJsReady:YES];
107
+ [self.emitter addListener:@"evt"];
108
+ [self.bridge resetLastJSCallForTesting];
109
+
110
+ [self.emitter sendEventWithName:@"evt" body:nil];
111
+
112
+ XCTAssertEqualObjects(self.bridge.lastArgs, (@[ @"rnfb_evt" ]));
113
+ }
114
+
115
+ - (void)testNotifyJsReadyFlushesQueuedEvents {
116
+ self.emitter.bridge = self.bridge;
117
+ [self.emitter addListener:@"evt"];
118
+ [self.emitter sendEventWithName:@"evt" body:@{@"a" : @1}];
119
+ [self.bridge resetLastJSCallForTesting];
120
+
121
+ [self.emitter notifyJsReady:YES];
122
+
123
+ XCTAssertEqualObjects(self.bridge.lastArgs[0], @"rnfb_evt");
124
+ XCTAssertEqualObjects([self.emitter getListenersDictionary][@"queued"], @0);
125
+ }
126
+
127
+ - (void)testAddAndRemoveListeners {
128
+ [self.emitter addListener:@"evt"];
129
+ [self.emitter addListener:@"evt"];
130
+ XCTAssertEqualObjects([self.emitter getListenersDictionary][@"listeners"], @2);
131
+ XCTAssertEqualObjects([self.emitter getListenersDictionary][@"events"][@"evt"], @2);
132
+
133
+ [self.emitter removeListeners:@"evt" all:NO];
134
+ XCTAssertEqualObjects([self.emitter getListenersDictionary][@"events"][@"evt"], @1);
135
+
136
+ [self.emitter removeListeners:@"evt" all:YES];
137
+ XCTAssertNil([self.emitter getListenersDictionary][@"events"][@"evt"]);
138
+ XCTAssertEqualObjects([self.emitter getListenersDictionary][@"listeners"], @0);
139
+ }
140
+
141
+ @end
@@ -0,0 +1,100 @@
1
+ /**
2
+ * Copyright (c) 2016-present Invertase Limited & Contributors
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this library except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ #import <XCTest/XCTest.h>
18
+
19
+ #import "RNFBHandleMapStorage-Swift.inc"
20
+ #import "RNFBJSON.h"
21
+ #import "RNFBPreferences.h"
22
+ #import "RNFBSharedUtils.h"
23
+
24
+ @interface RNFBSharedUtilsConfigFacadeTests : XCTestCase
25
+ @end
26
+
27
+ @implementation RNFBSharedUtilsConfigFacadeTests
28
+
29
+ - (void)tearDown {
30
+ [[RNFBPreferences shared] remove:@"__rnfb_config_facade_prefs__"];
31
+ [[RNFBPreferences shared] remove:@"__rnfb_config_facade_bool__"];
32
+ [[RNFBPreferences shared] remove:@"__rnfb_config_facade_json_lose__"];
33
+ [super tearDown];
34
+ }
35
+
36
+ - (void)testFacadeConfigContainsViaPreferences {
37
+ NSString *key = @"__rnfb_config_facade_prefs__";
38
+ XCTAssertFalse([RNFBSharedUtils configContains:key]);
39
+
40
+ [[RNFBPreferences shared] setBooleanValue:key boolValue:YES];
41
+ XCTAssertTrue([RNFBSharedUtils configContains:key]);
42
+ }
43
+
44
+ - (void)testFacadeGetConfigBooleanValuePreferencesWins {
45
+ NSString *key = @"__rnfb_config_facade_bool__";
46
+ [[RNFBPreferences shared] setBooleanValue:key boolValue:YES];
47
+
48
+ XCTAssertTrue([RNFBSharedUtils getConfigBooleanValue:@"ConfigFacadeTests"
49
+ key:key
50
+ defaultValue:NO]);
51
+ }
52
+
53
+ - (void)testFacadeGetConfigBooleanValueMetaPathUsesDefault {
54
+ NSString *key = @"__rnfb_config_facade_missing_everywhere__";
55
+ // Absent from Preferences / JSON / Meta → Meta path with passed-in defaultValue.
56
+ XCTAssertFalse([RNFBSharedUtils getConfigBooleanValue:@"ConfigFacadeTests"
57
+ key:key
58
+ defaultValue:NO]);
59
+ XCTAssertTrue([RNFBSharedUtils getConfigBooleanValue:@"ConfigFacadeTests"
60
+ key:key
61
+ defaultValue:YES]);
62
+ XCTAssertFalse([RNFBSharedUtils configContains:key]);
63
+ }
64
+
65
+ - (void)testFacadeGetConfigBooleanValueJsonOverMeta {
66
+ NSString *key = @"__rnfb_config_facade_json_win__";
67
+ RNFBJSONImplementation *implementation =
68
+ [[RNFBJSONImplementation alloc] initWithJSONObject:@{key : @YES}];
69
+
70
+ // Temporarily swap the shared JSON implementation so the façade resolves JSON before Meta.
71
+ RNFBJSON *shared = [RNFBJSON shared];
72
+ id previous = [shared valueForKey:@"implementation"];
73
+ [shared setValue:implementation forKey:@"implementation"];
74
+
75
+ @try {
76
+ XCTAssertFalse([[RNFBPreferences shared] contains:key]);
77
+ XCTAssertTrue([RNFBSharedUtils configContains:key]);
78
+ XCTAssertTrue([RNFBSharedUtils getConfigBooleanValue:@"ConfigFacadeTests"
79
+ key:key
80
+ defaultValue:NO]);
81
+ } @finally {
82
+ [shared setValue:previous forKey:@"implementation"];
83
+ }
84
+ }
85
+
86
+ - (void)testFacadePublicSelectorsUnchanged {
87
+ XCTAssertTrue([RNFBSharedUtils respondsToSelector:@selector(configContains:)]);
88
+ XCTAssertTrue(
89
+ [RNFBSharedUtils respondsToSelector:@selector(getConfigBooleanValue:key:defaultValue:)]);
90
+
91
+ NSMethodSignature *contains =
92
+ [RNFBSharedUtils methodSignatureForSelector:@selector(configContains:)];
93
+ XCTAssertEqual(strcmp(contains.methodReturnType, @encode(BOOL)), 0);
94
+
95
+ NSMethodSignature *boolean = [RNFBSharedUtils
96
+ methodSignatureForSelector:@selector(getConfigBooleanValue:key:defaultValue:)];
97
+ XCTAssertEqual(strcmp(boolean.methodReturnType, @encode(BOOL)), 0);
98
+ }
99
+
100
+ @end
@@ -0,0 +1,234 @@
1
+ /**
2
+ * Copyright (c) 2016-present Invertase Limited & Contributors
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this library except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import Foundation
18
+ import XCTest
19
+
20
+ private final class RecordingConfigSource: NSObject, RNFBConfigBooleanProviding {
21
+ var containsCalls: [String] = []
22
+ var getBooleanCalls: [(key: String, defaultValue: Bool)] = []
23
+ var containsResult = false
24
+ var booleanResult = false
25
+ /// When true, `getBooleanValue` returns the passed-in `defaultValue` (Meta missing-key path).
26
+ var echoDefaultValue = false
27
+
28
+ func contains(_ key: String) -> Bool {
29
+ containsCalls.append(key)
30
+ return containsResult
31
+ }
32
+
33
+ func getBooleanValue(_ key: String, defaultValue: Bool) -> Bool {
34
+ getBooleanCalls.append((key, defaultValue))
35
+ if echoDefaultValue {
36
+ return defaultValue
37
+ }
38
+ return booleanResult
39
+ }
40
+ }
41
+
42
+ final class RNFBSharedUtilsConfigTests: XCTestCase {
43
+ private let key = "rnfb.config.waterfall.test"
44
+
45
+ func testConfigContainsIsOrOfPreferencesJsonMeta() {
46
+ let preferences = RecordingConfigSource()
47
+ let json = RecordingConfigSource()
48
+ let meta = RecordingConfigSource()
49
+
50
+ preferences.containsResult = false
51
+ json.containsResult = false
52
+ meta.containsResult = false
53
+ XCTAssertFalse(
54
+ RNFBSharedUtilsConfig.configContains(
55
+ key,
56
+ preferences: preferences,
57
+ json: json,
58
+ meta: meta
59
+ )
60
+ )
61
+
62
+ meta.containsResult = true
63
+ XCTAssertTrue(
64
+ RNFBSharedUtilsConfig.configContains(
65
+ key,
66
+ preferences: preferences,
67
+ json: json,
68
+ meta: meta
69
+ )
70
+ )
71
+
72
+ json.containsResult = true
73
+ meta.containsResult = false
74
+ XCTAssertTrue(
75
+ RNFBSharedUtilsConfig.configContains(
76
+ key,
77
+ preferences: preferences,
78
+ json: json,
79
+ meta: meta
80
+ )
81
+ )
82
+
83
+ preferences.containsResult = true
84
+ json.containsResult = false
85
+ XCTAssertTrue(
86
+ RNFBSharedUtilsConfig.configContains(
87
+ key,
88
+ preferences: preferences,
89
+ json: json,
90
+ meta: meta
91
+ )
92
+ )
93
+ }
94
+
95
+ func testConfigContainsShortCircuitsLeftToRight() {
96
+ let preferences = RecordingConfigSource()
97
+ let json = RecordingConfigSource()
98
+ let meta = RecordingConfigSource()
99
+ preferences.containsResult = true
100
+
101
+ XCTAssertTrue(
102
+ RNFBSharedUtilsConfig.configContains(
103
+ key,
104
+ preferences: preferences,
105
+ json: json,
106
+ meta: meta
107
+ )
108
+ )
109
+ XCTAssertEqual(preferences.containsCalls, [key])
110
+ XCTAssertTrue(json.containsCalls.isEmpty)
111
+ XCTAssertTrue(meta.containsCalls.isEmpty)
112
+
113
+ preferences.containsResult = false
114
+ json.containsResult = true
115
+ preferences.containsCalls.removeAll()
116
+ json.containsCalls.removeAll()
117
+ meta.containsCalls.removeAll()
118
+
119
+ XCTAssertTrue(
120
+ RNFBSharedUtilsConfig.configContains(
121
+ key,
122
+ preferences: preferences,
123
+ json: json,
124
+ meta: meta
125
+ )
126
+ )
127
+ XCTAssertEqual(preferences.containsCalls, [key])
128
+ XCTAssertEqual(json.containsCalls, [key])
129
+ XCTAssertTrue(meta.containsCalls.isEmpty)
130
+ }
131
+
132
+ func testGetConfigBooleanValuePreferencesWinsOverJsonAndMeta() {
133
+ let preferences = RecordingConfigSource()
134
+ let json = RecordingConfigSource()
135
+ let meta = RecordingConfigSource()
136
+ preferences.containsResult = true
137
+ preferences.booleanResult = true
138
+ json.containsResult = true
139
+ json.booleanResult = false
140
+ meta.containsResult = true
141
+ meta.booleanResult = false
142
+
143
+ XCTAssertTrue(
144
+ RNFBSharedUtilsConfig.getConfigBooleanValue(
145
+ forKey: key,
146
+ defaultValue: false,
147
+ preferences: preferences,
148
+ json: json,
149
+ meta: meta
150
+ )
151
+ )
152
+ XCTAssertEqual(preferences.getBooleanCalls.count, 1)
153
+ XCTAssertTrue(json.getBooleanCalls.isEmpty)
154
+ XCTAssertTrue(meta.getBooleanCalls.isEmpty)
155
+ }
156
+
157
+ func testGetConfigBooleanValueJsonWinsOverMeta() {
158
+ let preferences = RecordingConfigSource()
159
+ let json = RecordingConfigSource()
160
+ let meta = RecordingConfigSource()
161
+ preferences.containsResult = false
162
+ json.containsResult = true
163
+ json.booleanResult = true
164
+ meta.containsResult = true
165
+ meta.booleanResult = false
166
+
167
+ XCTAssertTrue(
168
+ RNFBSharedUtilsConfig.getConfigBooleanValue(
169
+ forKey: key,
170
+ defaultValue: false,
171
+ preferences: preferences,
172
+ json: json,
173
+ meta: meta
174
+ )
175
+ )
176
+ XCTAssertTrue(preferences.getBooleanCalls.isEmpty)
177
+ XCTAssertEqual(json.getBooleanCalls.count, 1)
178
+ XCTAssertTrue(meta.getBooleanCalls.isEmpty)
179
+ }
180
+
181
+ func testGetConfigBooleanValueMetaPathUsesPassedInDefault() {
182
+ let preferences = RecordingConfigSource()
183
+ let json = RecordingConfigSource()
184
+ let meta = RecordingConfigSource()
185
+ preferences.containsResult = false
186
+ json.containsResult = false
187
+ // Meta missing-key path forwards the caller defaultValue.
188
+ meta.echoDefaultValue = true
189
+
190
+ XCTAssertTrue(
191
+ RNFBSharedUtilsConfig.getConfigBooleanValue(
192
+ forKey: key,
193
+ defaultValue: true,
194
+ preferences: preferences,
195
+ json: json,
196
+ meta: meta
197
+ )
198
+ )
199
+ XCTAssertFalse(
200
+ RNFBSharedUtilsConfig.getConfigBooleanValue(
201
+ forKey: key,
202
+ defaultValue: false,
203
+ preferences: preferences,
204
+ json: json,
205
+ meta: meta
206
+ )
207
+ )
208
+ XCTAssertEqual(meta.getBooleanCalls.count, 2)
209
+ XCTAssertEqual(meta.getBooleanCalls[0].defaultValue, true)
210
+ XCTAssertEqual(meta.getBooleanCalls[1].defaultValue, false)
211
+ XCTAssertTrue(preferences.getBooleanCalls.isEmpty)
212
+ XCTAssertTrue(json.getBooleanCalls.isEmpty)
213
+ }
214
+
215
+ func testGetConfigBooleanValueMetaPathReturnsSourceValue() {
216
+ let preferences = RecordingConfigSource()
217
+ let json = RecordingConfigSource()
218
+ let meta = RecordingConfigSource()
219
+ preferences.containsResult = false
220
+ json.containsResult = false
221
+ meta.booleanResult = true
222
+
223
+ XCTAssertTrue(
224
+ RNFBSharedUtilsConfig.getConfigBooleanValue(
225
+ forKey: key,
226
+ defaultValue: false,
227
+ preferences: preferences,
228
+ json: json,
229
+ meta: meta
230
+ )
231
+ )
232
+ XCTAssertEqual(meta.getBooleanCalls[0].defaultValue, false)
233
+ }
234
+ }
@@ -0,0 +1,145 @@
1
+ /**
2
+ * Copyright (c) 2016-present Invertase Limited & Contributors
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this library except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ #import <XCTest/XCTest.h>
18
+
19
+ #import <React/RCTBridge.h>
20
+
21
+ #import "FirebaseCore/FirebaseCore.h"
22
+ #import "RNFBAppModule.h"
23
+ #import "RNFBHandleMapStorage-Swift.inc"
24
+ #import "RNFBRCTEventEmitter.h"
25
+ #import "RNFBSharedUtils.h"
26
+
27
+ @interface RNFBAppModule (Testing)
28
+ + (void)setCustomDomainForTesting:(NSString *)domain forAppName:(NSString *)appName;
29
+ + (void)resetCustomDomainsForTesting;
30
+ @end
31
+
32
+ @interface RNFBSharedUtilsFIRAppFacadeTests : XCTestCase
33
+ @end
34
+
35
+ @implementation RNFBSharedUtilsFIRAppFacadeTests
36
+
37
+ - (FIROptions *)fullyPopulatedOptions {
38
+ FIROptions *options = [[FIROptions alloc] init];
39
+ options.APIKey = @"api-key";
40
+ options.googleAppID = @"app-id";
41
+ options.projectID = @"project-id";
42
+ options.databaseURL = @"https://example.firebaseio.com";
43
+ options.storageBucket = @"example.appspot.com";
44
+ options.GCMSenderID = @"sender-id";
45
+ options.clientID = @"client-id";
46
+ return options;
47
+ }
48
+
49
+ - (void)tearDown {
50
+ [RNFBAppModule resetCustomDomainsForTesting];
51
+ RNFBRCTEventEmitter *emitter = [RNFBRCTEventEmitter shared];
52
+ // Rebuild a core whose bridge/emit closures capture *shared*, not a disposable
53
+ // template (stealing template.core leaves dangling weakSelf → permanent queue-only).
54
+ __weak RNFBRCTEventEmitter *weakEmitter = emitter;
55
+ RNFBRCTEventEmitterCore *restoredCore = [[RNFBRCTEventEmitterCore alloc]
56
+ initWithIsBridgePresent:^BOOL {
57
+ return weakEmitter.bridge != nil;
58
+ }
59
+ emitHandler:^(NSString *eventName, id body) {
60
+ __strong RNFBRCTEventEmitter *strongEmitter = weakEmitter;
61
+ NSString *prefixedEventName = [@"rnfb_" stringByAppendingString:eventName];
62
+ [strongEmitter.bridge
63
+ enqueueJSCall:@"RCTDeviceEventEmitter"
64
+ method:@"emit"
65
+ args:body ? @[ prefixedEventName, body ] : @[ prefixedEventName ]
66
+ completion:NULL];
67
+ }];
68
+ [emitter setValue:restoredCore forKey:@"core"];
69
+ [emitter invalidate];
70
+ emitter.bridge = nil;
71
+ [super tearDown];
72
+ }
73
+
74
+ - (void)testFacadeDefaultNameMappingAndOptions {
75
+ FIRApp *app = [[FIRApp alloc] initWithName:DEFAULT_APP_NAME options:[self fullyPopulatedOptions]];
76
+ [app setDataCollectionDefaultEnabled:YES];
77
+
78
+ NSDictionary *result = [RNFBSharedUtils firAppToDictionary:app];
79
+ NSDictionary *appConfig = result[@"appConfig"];
80
+ NSDictionary *options = result[@"options"];
81
+
82
+ XCTAssertEqualObjects(appConfig[@"name"], DEFAULT_APP_DISPLAY_NAME);
83
+ XCTAssertEqualObjects(appConfig[@"automaticDataCollectionEnabled"], @YES);
84
+ XCTAssertEqualObjects(options[@"apiKey"], @"api-key");
85
+ XCTAssertEqualObjects(options[@"appId"], @"app-id");
86
+ XCTAssertEqualObjects(options[@"projectId"], @"project-id");
87
+ XCTAssertEqualObjects(options[@"databaseURL"], @"https://example.firebaseio.com");
88
+ XCTAssertEqualObjects(options[@"storageBucket"], @"example.appspot.com");
89
+ XCTAssertEqualObjects(options[@"messagingSenderId"], @"sender-id");
90
+ XCTAssertEqualObjects(options[@"clientId"], @"client-id");
91
+ XCTAssertNil(options[@"authDomain"]);
92
+ }
93
+
94
+ - (void)testFacadeAuthDomainPresentAndAbsent {
95
+ FIRApp *app = [[FIRApp alloc] initWithName:@"secondary" options:[self fullyPopulatedOptions]];
96
+
97
+ NSDictionary *withoutDomain = [RNFBSharedUtils firAppToDictionary:app];
98
+ XCTAssertNil(withoutDomain[@"options"][@"authDomain"]);
99
+
100
+ [RNFBAppModule setCustomDomainForTesting:@"custom.example.com" forAppName:@"secondary"];
101
+ NSDictionary *withDomain = [RNFBSharedUtils firAppToDictionary:app];
102
+ XCTAssertEqualObjects(withDomain[@"options"][@"authDomain"], @"custom.example.com");
103
+ }
104
+
105
+ - (void)testFacadeAuthDomainUsesMappedDefaultName {
106
+ FIRApp *app = [[FIRApp alloc] initWithName:DEFAULT_APP_NAME options:[self fullyPopulatedOptions]];
107
+ [RNFBAppModule setCustomDomainForTesting:@"default-domain.example.com"
108
+ forAppName:DEFAULT_APP_DISPLAY_NAME];
109
+
110
+ NSDictionary *result = [RNFBSharedUtils firAppToDictionary:app];
111
+ XCTAssertEqualObjects(result[@"options"][@"authDomain"], @"default-domain.example.com");
112
+ }
113
+
114
+ - (void)testFacadeSendJSEventInjectsAppNameAndForwards {
115
+ FIRApp *app = [[FIRApp alloc] initWithName:DEFAULT_APP_NAME options:[self fullyPopulatedOptions]];
116
+ RNFBRCTEventEmitter *emitter = [RNFBRCTEventEmitter shared];
117
+ [emitter invalidate];
118
+
119
+ __block NSString *capturedName = nil;
120
+ __block NSDictionary *capturedBody = nil;
121
+ RNFBRCTEventEmitterCore *recordingCore = [[RNFBRCTEventEmitterCore alloc]
122
+ initWithIsBridgePresent:^BOOL {
123
+ return YES;
124
+ }
125
+ emitHandler:^(NSString *eventName, id body) {
126
+ capturedName = [eventName copy];
127
+ capturedBody = body;
128
+ }];
129
+ [emitter setValue:recordingCore forKey:@"core"];
130
+ [emitter notifyJsReady:YES];
131
+ [emitter addListener:@"facade_event"];
132
+
133
+ [RNFBSharedUtils sendJSEventForApp:app name:@"facade_event" body:@{@"foo" : @"bar"}];
134
+
135
+ XCTAssertEqualObjects(capturedName, @"facade_event");
136
+ XCTAssertEqualObjects(capturedBody[@"foo"], @"bar");
137
+ XCTAssertEqualObjects(capturedBody[@"appName"], DEFAULT_APP_DISPLAY_NAME);
138
+ }
139
+
140
+ - (void)testFacadePublicSelectorsUnchanged {
141
+ XCTAssertTrue([RNFBSharedUtils respondsToSelector:@selector(firAppToDictionary:)]);
142
+ XCTAssertTrue([RNFBSharedUtils respondsToSelector:@selector(sendJSEventForApp:name:body:)]);
143
+ }
144
+
145
+ @end