@bugsee/react-native 0.0.0-stage → 7.0.0-beta2

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 (250) hide show
  1. package/BugseeReactNative.podspec +95 -0
  2. package/LICENSE +21 -0
  3. package/README.md +557 -2
  4. package/android/build.gradle +162 -0
  5. package/android/consumer-rules.pro +2 -0
  6. package/android/src/main/AndroidManifest.xml +33 -0
  7. package/android/src/main/java/com/bugsee/reactnative/AppearanceBridge.java +82 -0
  8. package/android/src/main/java/com/bugsee/reactnative/AttributeBridge.java +209 -0
  9. package/android/src/main/java/com/bugsee/reactnative/BreadcrumbFilterBridge.java +443 -0
  10. package/android/src/main/java/com/bugsee/reactnative/BridgeJson.java +168 -0
  11. package/android/src/main/java/com/bugsee/reactnative/BugseeModule.java +1869 -0
  12. package/android/src/main/java/com/bugsee/reactnative/BugseeOptionEnums.java +136 -0
  13. package/android/src/main/java/com/bugsee/reactnative/BugseePackage.java +42 -0
  14. package/android/src/main/java/com/bugsee/reactnative/BugseeReactNativeWrapper.java +200 -0
  15. package/android/src/main/java/com/bugsee/reactnative/BugseeStatusMapper.java +66 -0
  16. package/android/src/main/java/com/bugsee/reactnative/BugseeTokens.java +22 -0
  17. package/android/src/main/java/com/bugsee/reactnative/ConsoleEchoDedup.java +202 -0
  18. package/android/src/main/java/com/bugsee/reactnative/CreatedReports.java +127 -0
  19. package/android/src/main/java/com/bugsee/reactnative/DataRequestBridge.java +375 -0
  20. package/android/src/main/java/com/bugsee/reactnative/ExceptionBridge.java +88 -0
  21. package/android/src/main/java/com/bugsee/reactnative/ExceptionExecutors.java +33 -0
  22. package/android/src/main/java/com/bugsee/reactnative/LogFilterBridge.java +375 -0
  23. package/android/src/main/java/com/bugsee/reactnative/NetworkEvents.java +227 -0
  24. package/android/src/main/java/com/bugsee/reactnative/NetworkFilterBridge.java +498 -0
  25. package/android/src/main/java/com/bugsee/reactnative/PluginEndpoint.java +48 -0
  26. package/android/src/main/java/com/bugsee/reactnative/ReactNativeWebException.java +19 -0
  27. package/android/src/main/java/com/bugsee/reactnative/ReactNativeWrapperInitProvider.java +61 -0
  28. package/android/src/main/java/com/bugsee/reactnative/ReactRootOriginTracker.java +867 -0
  29. package/android/src/main/java/com/bugsee/reactnative/ReportArgs.java +58 -0
  30. package/android/src/main/java/com/bugsee/reactnative/ReportHandlerBridge.java +336 -0
  31. package/android/src/main/java/com/bugsee/reactnative/ReportHandlerDeadlines.java +57 -0
  32. package/android/src/main/java/com/bugsee/reactnative/ReportOps.java +287 -0
  33. package/android/src/main/java/com/bugsee/reactnative/SecureRectanglePulls.java +113 -0
  34. package/android/src/main/java/com/bugsee/reactnative/SecureRectangleStore.java +692 -0
  35. package/android/src/main/java/com/bugsee/reactnative/SpanHandles.java +143 -0
  36. package/android/src/main/java/com/bugsee/reactnative/WrapperChannelHolder.java +137 -0
  37. package/android/src/main/java/com/bugsee/reactnative/WrapperEventBus.java +110 -0
  38. package/android/src/main/java/com/bugsee/reactnative/WrapperRegistrar.java +54 -0
  39. package/app.plugin.js +4 -0
  40. package/ios/BGSRNConsoleCapture.h +52 -0
  41. package/ios/BGSRNConsoleCapture.mm +344 -0
  42. package/ios/BugseeModule.h +25 -0
  43. package/ios/BugseeModule.mm +2728 -0
  44. package/ios/Package.swift +71 -0
  45. package/ios/Support/Package.resolved +14 -0
  46. package/ios/Support/Package.swift +44 -0
  47. package/ios/Support/Sources/BugseeRNSupport/BGSRNAttributes.m +52 -0
  48. package/ios/Support/Sources/BugseeRNSupport/BGSRNCreatedReportOps.m +236 -0
  49. package/ios/Support/Sources/BugseeRNSupport/BGSRNCreatedReports.m +184 -0
  50. package/ios/Support/Sources/BugseeRNSupport/BGSRNDataRequestBridge.m +431 -0
  51. package/ios/Support/Sources/BugseeRNSupport/BGSRNErrorMessage.m +40 -0
  52. package/ios/Support/Sources/BugseeRNSupport/BGSRNEventBus.m +70 -0
  53. package/ios/Support/Sources/BugseeRNSupport/BGSRNExceptions.m +63 -0
  54. package/ios/Support/Sources/BugseeRNSupport/BGSRNGuardedEmit.mm +32 -0
  55. package/ios/Support/Sources/BugseeRNSupport/BGSRNJSON.m +40 -0
  56. package/ios/Support/Sources/BugseeRNSupport/BGSRNLaunchHold.m +147 -0
  57. package/ios/Support/Sources/BugseeRNSupport/BGSRNMainThread.m +23 -0
  58. package/ios/Support/Sources/BugseeRNSupport/BGSRNNetworkEvents.m +159 -0
  59. package/ios/Support/Sources/BugseeRNSupport/BGSRNNetworkFilter.m +155 -0
  60. package/ios/Support/Sources/BugseeRNSupport/BGSRNPluginEndpoint.m +21 -0
  61. package/ios/Support/Sources/BugseeRNSupport/BGSRNReactRootOriginTracker.m +63 -0
  62. package/ios/Support/Sources/BugseeRNSupport/BGSRNReactWindow.m +251 -0
  63. package/ios/Support/Sources/BugseeRNSupport/BGSRNReportArgs.m +47 -0
  64. package/ios/Support/Sources/BugseeRNSupport/BGSRNReportDeadlines.m +8 -0
  65. package/ios/Support/Sources/BugseeRNSupport/BGSRNReportHandlerBridge.m +308 -0
  66. package/ios/Support/Sources/BugseeRNSupport/BGSRNReportOps.m +345 -0
  67. package/ios/Support/Sources/BugseeRNSupport/BGSRNSecureRectangles.m +508 -0
  68. package/ios/Support/Sources/BugseeRNSupport/BGSRNSettleOnce.m +62 -0
  69. package/ios/Support/Sources/BugseeRNSupport/BGSRNSpanHandles.m +136 -0
  70. package/ios/Support/Sources/BugseeRNSupport/BGSRNStatusMapper.m +18 -0
  71. package/ios/Support/Sources/BugseeRNSupport/BGSRNTokens.m +9 -0
  72. package/ios/Support/Sources/BugseeRNSupport/BGSRNValues.m +5 -0
  73. package/ios/Support/Sources/BugseeRNSupport/BGSRNWrapper.m +54 -0
  74. package/ios/Support/Sources/BugseeRNSupport/BGSRNWrapperChannelHolder.m +59 -0
  75. package/ios/Support/Sources/BugseeRNSupport/include/BGSRNAttributes.h +63 -0
  76. package/ios/Support/Sources/BugseeRNSupport/include/BGSRNCreatedReportOps.h +51 -0
  77. package/ios/Support/Sources/BugseeRNSupport/include/BGSRNCreatedReports.h +81 -0
  78. package/ios/Support/Sources/BugseeRNSupport/include/BGSRNDataRequestBridge.h +118 -0
  79. package/ios/Support/Sources/BugseeRNSupport/include/BGSRNErrorMessage.h +30 -0
  80. package/ios/Support/Sources/BugseeRNSupport/include/BGSRNEventBus.h +45 -0
  81. package/ios/Support/Sources/BugseeRNSupport/include/BGSRNExceptions.h +31 -0
  82. package/ios/Support/Sources/BugseeRNSupport/include/BGSRNGuardedEmit.h +31 -0
  83. package/ios/Support/Sources/BugseeRNSupport/include/BGSRNJSON.h +25 -0
  84. package/ios/Support/Sources/BugseeRNSupport/include/BGSRNLaunchHold.h +86 -0
  85. package/ios/Support/Sources/BugseeRNSupport/include/BGSRNMainThread.h +32 -0
  86. package/ios/Support/Sources/BugseeRNSupport/include/BGSRNNetworkEvents.h +28 -0
  87. package/ios/Support/Sources/BugseeRNSupport/include/BGSRNNetworkFilter.h +28 -0
  88. package/ios/Support/Sources/BugseeRNSupport/include/BGSRNPluginEndpoint.h +17 -0
  89. package/ios/Support/Sources/BugseeRNSupport/include/BGSRNReactRootOriginTracker.h +48 -0
  90. package/ios/Support/Sources/BugseeRNSupport/include/BGSRNReactWindow.h +135 -0
  91. package/ios/Support/Sources/BugseeRNSupport/include/BGSRNReportArgs.h +17 -0
  92. package/ios/Support/Sources/BugseeRNSupport/include/BGSRNReportDeadlines.h +37 -0
  93. package/ios/Support/Sources/BugseeRNSupport/include/BGSRNReportHandlerBridge.h +94 -0
  94. package/ios/Support/Sources/BugseeRNSupport/include/BGSRNReportOps.h +86 -0
  95. package/ios/Support/Sources/BugseeRNSupport/include/BGSRNSecureRectangles.h +198 -0
  96. package/ios/Support/Sources/BugseeRNSupport/include/BGSRNSettleOnce.h +25 -0
  97. package/ios/Support/Sources/BugseeRNSupport/include/BGSRNSpanHandles.h +49 -0
  98. package/ios/Support/Sources/BugseeRNSupport/include/BGSRNStatusMapper.h +26 -0
  99. package/ios/Support/Sources/BugseeRNSupport/include/BGSRNTokens.h +14 -0
  100. package/ios/Support/Sources/BugseeRNSupport/include/BGSRNValues.h +18 -0
  101. package/ios/Support/Sources/BugseeRNSupport/include/BGSRNWrapper.h +40 -0
  102. package/ios/Support/Sources/BugseeRNSupport/include/BGSRNWrapperChannelHolder.h +74 -0
  103. package/ios/Support/Tests/BugseeRNSupportTests/BGSRNAttributesTests.m +194 -0
  104. package/ios/Support/Tests/BugseeRNSupportTests/BGSRNCreatedReportOpsTests.m +274 -0
  105. package/ios/Support/Tests/BugseeRNSupportTests/BGSRNCreatedReportsTests.m +240 -0
  106. package/ios/Support/Tests/BugseeRNSupportTests/BGSRNDataRequestBridgeTests.m +685 -0
  107. package/ios/Support/Tests/BugseeRNSupportTests/BGSRNErrorMessageTests.m +102 -0
  108. package/ios/Support/Tests/BugseeRNSupportTests/BGSRNEventBusTests.m +136 -0
  109. package/ios/Support/Tests/BugseeRNSupportTests/BGSRNExceptionsTests.m +68 -0
  110. package/ios/Support/Tests/BugseeRNSupportTests/BGSRNFakeReport.h +41 -0
  111. package/ios/Support/Tests/BugseeRNSupportTests/BGSRNFakeReport.m +166 -0
  112. package/ios/Support/Tests/BugseeRNSupportTests/BGSRNGuardedEmitTests.mm +85 -0
  113. package/ios/Support/Tests/BugseeRNSupportTests/BGSRNJSONTests.m +281 -0
  114. package/ios/Support/Tests/BugseeRNSupportTests/BGSRNLaunchHoldTests.m +230 -0
  115. package/ios/Support/Tests/BugseeRNSupportTests/BGSRNMainThreadTests.m +97 -0
  116. package/ios/Support/Tests/BugseeRNSupportTests/BGSRNNetworkEventsTests.m +99 -0
  117. package/ios/Support/Tests/BugseeRNSupportTests/BGSRNNetworkFilterTests.m +134 -0
  118. package/ios/Support/Tests/BugseeRNSupportTests/BGSRNPluginEndpointTests.m +38 -0
  119. package/ios/Support/Tests/BugseeRNSupportTests/BGSRNReactRootOriginTrackerTests.m +210 -0
  120. package/ios/Support/Tests/BugseeRNSupportTests/BGSRNReactWindowTests.m +548 -0
  121. package/ios/Support/Tests/BugseeRNSupportTests/BGSRNReportArgsTests.m +51 -0
  122. package/ios/Support/Tests/BugseeRNSupportTests/BGSRNReportDeadlinesTests.m +22 -0
  123. package/ios/Support/Tests/BugseeRNSupportTests/BGSRNReportHandlerBridgeTests.m +382 -0
  124. package/ios/Support/Tests/BugseeRNSupportTests/BGSRNReportOpsTests.m +295 -0
  125. package/ios/Support/Tests/BugseeRNSupportTests/BGSRNSecureRectanglesTests.m +568 -0
  126. package/ios/Support/Tests/BugseeRNSupportTests/BGSRNSettleOnceTests.m +134 -0
  127. package/ios/Support/Tests/BugseeRNSupportTests/BGSRNSpanHandlesTests.m +153 -0
  128. package/ios/Support/Tests/BugseeRNSupportTests/BGSRNStatusMapperTests.m +81 -0
  129. package/ios/Support/Tests/BugseeRNSupportTests/BGSRNValuesTests.m +32 -0
  130. package/ios/Support/Tests/BugseeRNSupportTests/BGSRNWrapperChannelHolderTests.m +205 -0
  131. package/ios/Support/Tests/BugseeRNSupportTests/BGSRNWrapperTests.m +66 -0
  132. package/ios/react-native-spm-prefix.h +10 -0
  133. package/native-versions.json +10 -0
  134. package/package.json +62 -3
  135. package/plugin/build/bundle-phase.d.ts +41 -0
  136. package/plugin/build/bundle-phase.js +116 -0
  137. package/plugin/build/bundle-phase.js.map +1 -0
  138. package/plugin/build/dsym-script.d.ts +32 -0
  139. package/plugin/build/dsym-script.js +159 -0
  140. package/plugin/build/dsym-script.js.map +1 -0
  141. package/plugin/build/endpoint.d.ts +30 -0
  142. package/plugin/build/endpoint.js +69 -0
  143. package/plugin/build/endpoint.js.map +1 -0
  144. package/plugin/build/gradle.d.ts +65 -0
  145. package/plugin/build/gradle.js +1066 -0
  146. package/plugin/build/gradle.js.map +1 -0
  147. package/plugin/build/index.d.ts +85 -0
  148. package/plugin/build/index.js +217 -0
  149. package/plugin/build/index.js.map +1 -0
  150. package/plugin/build/manifest.d.ts +48 -0
  151. package/plugin/build/manifest.js +69 -0
  152. package/plugin/build/manifest.js.map +1 -0
  153. package/plugin/build/native-versions.baked.json +4 -0
  154. package/plugin/build/native-versions.d.ts +10 -0
  155. package/plugin/build/native-versions.js +27 -0
  156. package/plugin/build/native-versions.js.map +1 -0
  157. package/plugin/build/pbx-string.d.ts +8 -0
  158. package/plugin/build/pbx-string.js +31 -0
  159. package/plugin/build/pbx-string.js.map +1 -0
  160. package/plugin/build/podfile.d.ts +3 -0
  161. package/plugin/build/podfile.js +28 -0
  162. package/plugin/build/podfile.js.map +1 -0
  163. package/plugin/build/properties.d.ts +19 -0
  164. package/plugin/build/properties.js +41 -0
  165. package/plugin/build/properties.js.map +1 -0
  166. package/plugin/build/scheme.d.ts +20 -0
  167. package/plugin/build/scheme.js +107 -0
  168. package/plugin/build/scheme.js.map +1 -0
  169. package/react-native.config.js +26 -0
  170. package/scripts/bugsee-sourcemaps.gradle +201 -0
  171. package/scripts/bugsee-xcode.sh +83 -0
  172. package/scripts/compose-then-inject.js +113 -0
  173. package/scripts/hermes-sourcemaps.js +634 -0
  174. package/scripts/hermesc-preserve-js.cmd +6 -0
  175. package/scripts/hermesc-preserve-js.js +200 -0
  176. package/scripts/hermesc-preserve-js.sh +7 -0
  177. package/src/NativeBugsee.ts +622 -0
  178. package/src/apm/notify.ts +58 -0
  179. package/src/apm/span.ts +403 -0
  180. package/src/apm/types.ts +57 -0
  181. package/src/appearance/report.ts +171 -0
  182. package/src/architecture.ts +48 -0
  183. package/src/attributes/errors.ts +39 -0
  184. package/src/attributes/validate.ts +150 -0
  185. package/src/breadcrumbs/add.ts +58 -0
  186. package/src/breadcrumbs/data.ts +33 -0
  187. package/src/breadcrumbs/filter.ts +215 -0
  188. package/src/breadcrumbs/types.ts +64 -0
  189. package/src/bridge/json.ts +110 -0
  190. package/src/console/capture.ts +180 -0
  191. package/src/console/dedup.ts +175 -0
  192. package/src/data/validate.ts +259 -0
  193. package/src/errorName.ts +32 -0
  194. package/src/exceptions/ErrorBoundary.tsx +92 -0
  195. package/src/exceptions/RootErrorReporter.tsx +61 -0
  196. package/src/exceptions/debugIds.ts +118 -0
  197. package/src/exceptions/handlers.ts +236 -0
  198. package/src/exceptions/options.ts +85 -0
  199. package/src/exceptions/payload.ts +456 -0
  200. package/src/exceptions/report.ts +170 -0
  201. package/src/exceptions/sha1.ts +148 -0
  202. package/src/exceptions/stack.ts +355 -0
  203. package/src/index.ts +962 -0
  204. package/src/logs/filter.ts +90 -0
  205. package/src/logs/log.ts +36 -0
  206. package/src/network/add.ts +165 -0
  207. package/src/network/filter.ts +198 -0
  208. package/src/options/AndroidLaunchOptions.ts +78 -0
  209. package/src/options/BugseeLaunchOptions.ts +190 -0
  210. package/src/options/IOSLaunchOptions.ts +57 -0
  211. package/src/options/android-options-manifest.json +646 -0
  212. package/src/options/createDefaultLaunchOptions.ts +29 -0
  213. package/src/options/endpoint.ts +58 -0
  214. package/src/options/enums.ts +104 -0
  215. package/src/options/ios-enums.json +19 -0
  216. package/src/options/keys.ts +39 -0
  217. package/src/options/option-enums.json +34 -0
  218. package/src/options/option-keys.json +107 -0
  219. package/src/report/BugseeReport.ts +264 -0
  220. package/src/report/CreatedReport.ts +127 -0
  221. package/src/report/dispatcher.ts +95 -0
  222. package/src/report/errors.ts +48 -0
  223. package/src/report/fields.ts +40 -0
  224. package/src/report/types.ts +157 -0
  225. package/src/report/validate.ts +197 -0
  226. package/src/secure/BugseeSecure.tsx +202 -0
  227. package/src/secure/ancestry.ts +622 -0
  228. package/src/secure/drivers.ts +342 -0
  229. package/src/secure/followEvents.ts +57 -0
  230. package/src/secure/hold.ts +99 -0
  231. package/src/secure/measureLoop.ts +323 -0
  232. package/src/secure/nativeAnimation.ts +1005 -0
  233. package/src/secure/rectangles.ts +93 -0
  234. package/src/secure/registry.ts +237 -0
  235. package/src/secure/surface.ts +83 -0
  236. package/src/secure/tracker.ts +723 -0
  237. package/src/secure/transition.ts +488 -0
  238. package/src/secure/unit.ts +22 -0
  239. package/src/status.ts +16 -0
  240. package/src/version.ts +9 -0
  241. package/src/viewtree/anchor.tsx +105 -0
  242. package/src/viewtree/constants.ts +20 -0
  243. package/src/viewtree/fiber.ts +251 -0
  244. package/src/viewtree/requests.ts +347 -0
  245. package/src/viewtree/walk.ts +902 -0
  246. package/src/wrapper/channel.ts +33 -0
  247. package/src/wrapper/collect.ts +52 -0
  248. package/src/wrapper/events.ts +45 -0
  249. package/src/wrapper/identity.ts +54 -0
  250. package/src/wrapper/lifecycle-events.ts +89 -0
@@ -0,0 +1,102 @@
1
+ @import XCTest;
2
+ @import Bugsee;
3
+ @import BugseeRNSupport;
4
+
5
+ /// `BGSRNErrorMessage` is the one place the bridge reads an `NSError`'s
6
+ /// message. It composes the bridge's OWN messages -- a literal description,
7
+ /// an identifier, an own underlying error -- and never passes a foreign
8
+ /// error's text, which can carry anything (a system parser echoes the
9
+ /// malformed input, a file error names the path).
10
+ @interface BGSRNErrorMessageTests : XCTestCase
11
+ @end
12
+
13
+ @implementation BGSRNErrorMessageTests
14
+
15
+ - (void)testPassesTheBridgesOwnDescriptionsThrough {
16
+ NSError *report = [NSError errorWithDomain:BGSRNReportErrorDomain
17
+ code:1
18
+ userInfo:@{NSLocalizedDescriptionKey : @"labels must all be strings"}];
19
+ NSError *json = [NSError errorWithDomain:BGSRNJSONErrorDomain
20
+ code:1
21
+ userInfo:@{NSLocalizedDescriptionKey : @"malformed JSON"}];
22
+ NSError *exceptions = [NSError errorWithDomain:BGSRNExceptionsErrorDomain
23
+ code:1
24
+ userInfo:@{NSLocalizedDescriptionKey : @"domain must be a string"}];
25
+ XCTAssertEqualObjects(BGSRNErrorMessage(report), @"labels must all be strings");
26
+ XCTAssertEqualObjects(BGSRNErrorMessage(json), @"malformed JSON");
27
+ XCTAssertEqualObjects(BGSRNErrorMessage(exceptions), @"domain must be a string");
28
+ }
29
+
30
+ - (void)testPutsTheIdentifierWhereTheDescriptionSays {
31
+ NSError *error = [NSError errorWithDomain:BGSRNReportErrorDomain
32
+ code:1
33
+ userInfo:@{
34
+ NSLocalizedDescriptionKey : @"unknown key \"{identifier}\"",
35
+ BGSRNErrorIdentifierKey : @"summray",
36
+ }];
37
+ XCTAssertEqualObjects(BGSRNErrorMessage(error), @"unknown key \"summray\"");
38
+ }
39
+
40
+ - (void)testIgnoresAnIdentifierThatIsNotAString {
41
+ NSError *error = [NSError errorWithDomain:BGSRNReportErrorDomain
42
+ code:1
43
+ userInfo:@{
44
+ NSLocalizedDescriptionKey : @"unknown key \"{identifier}\"",
45
+ BGSRNErrorIdentifierKey : @42,
46
+ }];
47
+ XCTAssertEqualObjects(BGSRNErrorMessage(error), @"unknown key \"{identifier}\"");
48
+ }
49
+
50
+ - (void)testAppendsAnOwnUnderlyingErrorOnly {
51
+ NSError *own = [NSError errorWithDomain:BGSRNJSONErrorDomain
52
+ code:1
53
+ userInfo:@{NSLocalizedDescriptionKey : @"malformed JSON"}];
54
+ NSError *foreign = [NSError errorWithDomain:NSCocoaErrorDomain
55
+ code:3840
56
+ userInfo:@{NSLocalizedDescriptionKey : @"s3cret-input"}];
57
+ NSError *withOwn = [NSError errorWithDomain:BGSRNReportErrorDomain
58
+ code:1
59
+ userInfo:@{
60
+ NSLocalizedDescriptionKey : @"patch is not a JSON object",
61
+ NSUnderlyingErrorKey : own,
62
+ }];
63
+ NSError *withForeign = [NSError errorWithDomain:BGSRNReportErrorDomain
64
+ code:1
65
+ userInfo:@{
66
+ NSLocalizedDescriptionKey : @"patch is not a JSON object",
67
+ NSUnderlyingErrorKey : foreign,
68
+ }];
69
+ NSError *withNull = [NSError errorWithDomain:BGSRNReportErrorDomain
70
+ code:1
71
+ userInfo:@{
72
+ NSLocalizedDescriptionKey : @"patch is not a JSON object",
73
+ NSUnderlyingErrorKey : NSNull.null,
74
+ }];
75
+ XCTAssertEqualObjects(BGSRNErrorMessage(withOwn), @"patch is not a JSON object: malformed JSON");
76
+ XCTAssertEqualObjects(BGSRNErrorMessage(withForeign), @"patch is not a JSON object");
77
+ XCTAssertEqualObjects(BGSRNErrorMessage(withNull), @"patch is not a JSON object");
78
+ }
79
+
80
+ - (void)testNeverPassesAForeignErrorsMessage {
81
+ NSError *foreign = [NSError errorWithDomain:NSCocoaErrorDomain
82
+ code:1
83
+ userInfo:@{NSLocalizedDescriptionKey : @"/private/var/mobile/s3cret-user/file.txt"}];
84
+ NSError *lookalike = [NSError errorWithDomain:@"BGSRNLookalikeDomain"
85
+ code:1
86
+ userInfo:@{NSLocalizedDescriptionKey : @"s3cret"}];
87
+ XCTAssertEqualObjects(BGSRNErrorMessage(foreign), BGSRNForeignErrorMessage);
88
+ XCTAssertEqualObjects(BGSRNErrorMessage(lookalike), BGSRNForeignErrorMessage);
89
+ }
90
+
91
+ - (void)testANilErrorIsTheFixedMessageToo {
92
+ XCTAssertEqualObjects(BGSRNErrorMessage(nil), BGSRNForeignErrorMessage);
93
+ }
94
+
95
+ /// A bridge error built without a description must not fall back to
96
+ /// Foundation's generated text, which names the domain and code.
97
+ - (void)testABridgeErrorWithoutADescriptionIsTheFixedMessage {
98
+ NSError *bare = [NSError errorWithDomain:BGSRNReportErrorDomain code:1 userInfo:nil];
99
+ XCTAssertEqualObjects(BGSRNErrorMessage(bare), BGSRNForeignErrorMessage);
100
+ }
101
+
102
+ @end
@@ -0,0 +1,136 @@
1
+ @import XCTest;
2
+ @import BugseeRNSupport;
3
+
4
+ /// The wrapper is registered before React Native exists, so lifecycle events
5
+ /// genuinely arrive with no bridge to deliver them to. That is the normal case
6
+ /// during start-up, not an error, and it is why the sink is separate from the
7
+ /// wrapper.
8
+ @interface BGSRNEventBusTests : XCTestCase
9
+ @end
10
+
11
+ @implementation BGSRNEventBusTests {
12
+ BGSRNEventBus *_bus;
13
+ NSMutableArray<NSString *> *_events;
14
+ }
15
+
16
+ - (void)setUp {
17
+ [super setUp];
18
+ _bus = [[BGSRNEventBus alloc] init];
19
+ _events = [NSMutableArray array];
20
+ }
21
+
22
+ - (void)attachRecorder:(id)owner {
23
+ // Captured directly rather than through the test case: dereferencing a weak
24
+ // pointer is an ARC error (the value can be nilled between load and use), and
25
+ // the array outlives the block regardless.
26
+ NSMutableArray<NSString *> *events = _events;
27
+ [_bus attach:owner block:^BOOL(NSString *name, NSString *reportId) {
28
+ [events addObject:[NSString stringWithFormat:@"%@/%@", name, reportId ?: @"nil"]];
29
+ return YES;
30
+ }];
31
+ }
32
+
33
+ /// A sink that could not emit (no JS emitter yet, or mid-reload) says so,
34
+ /// and the bus drops the event without unwinding anything through the
35
+ /// SDK's dispatch thread.
36
+ - (void)testASinkThatCannotDeliverIsDroppedQuietly {
37
+ NSObject *owner = [NSObject new];
38
+ __block NSUInteger calls = 0;
39
+ [_bus attach:owner block:^BOOL(NSString *name, NSString *reportId) {
40
+ calls += 1;
41
+ return NO;
42
+ }];
43
+
44
+ XCTAssertNoThrow([_bus emitLifecycle:@"com.bugsee.lifecycle.Launched" reportId:nil]);
45
+ XCTAssertEqual(calls, 1u);
46
+ }
47
+
48
+ - (void)testSwallowsEventsWhenNoBridgeIsAttached {
49
+ [_bus emitLifecycle:@"com.bugsee.lifecycle.Launching" reportId:nil];
50
+ XCTAssertEqual(_events.count, 0u);
51
+ }
52
+
53
+ - (void)testDeliversToTheAttachedSink {
54
+ NSObject *owner = [NSObject new];
55
+ [self attachRecorder:owner];
56
+
57
+ [_bus emitLifecycle:@"com.bugsee.lifecycle.Launched" reportId:nil];
58
+
59
+ XCTAssertEqualObjects(_events.firstObject, @"Launched/nil");
60
+ }
61
+
62
+ /// The prefix is stripped here so the wire payload matches what the JS type
63
+ /// says. Both SDKs dispatch the prefixed form.
64
+ - (void)testStripsTheLifecyclePrefix {
65
+ NSObject *owner = [NSObject new];
66
+ [self attachRecorder:owner];
67
+
68
+ [_bus emitLifecycle:@"com.bugsee.lifecycle.RelaunchedAfterCrash" reportId:nil];
69
+
70
+ XCTAssertEqualObjects(_events.firstObject, @"RelaunchedAfterCrash/nil");
71
+ }
72
+
73
+ /// A newer SDK adding an event must not have it silently swallowed by an older
74
+ /// wrapper — that is the failure mode that hides a whole feature.
75
+ - (void)testForwardsAnUnknownNameUnchanged {
76
+ NSObject *owner = [NSObject new];
77
+ [self attachRecorder:owner];
78
+
79
+ [_bus emitLifecycle:@"com.bugsee.lifecycle.SomethingNewIn8x" reportId:nil];
80
+ [_bus emitLifecycle:@"TotallyUnexpected" reportId:nil];
81
+
82
+ XCTAssertEqualObjects(_events[0], @"SomethingNewIn8x/nil");
83
+ XCTAssertEqualObjects(_events[1], @"TotallyUnexpected/nil");
84
+ }
85
+
86
+ - (void)testPassesTheReportIdWhenTheEventCarriesOne {
87
+ NSObject *owner = [NSObject new];
88
+ [self attachRecorder:owner];
89
+
90
+ [_bus emitLifecycle:@"com.bugsee.lifecycle.AfterReportUploaded" reportId:@"abc-123"];
91
+
92
+ XCTAssertEqualObjects(_events.firstObject, @"AfterReportUploaded/abc-123");
93
+ }
94
+
95
+ - (void)testStopsDeliveringAfterDetach {
96
+ NSObject *owner = [NSObject new];
97
+ [self attachRecorder:owner];
98
+ [_bus detach:owner];
99
+
100
+ [_bus emitLifecycle:@"com.bugsee.lifecycle.Launched" reportId:nil];
101
+
102
+ XCTAssertEqual(_events.count, 0u);
103
+ }
104
+
105
+ /// A fast reload can attach the new module before the old one is torn down;
106
+ /// the old one's detach must not silence the new one.
107
+ - (void)testDetachingAStaleSinkLeavesTheCurrentOneAttached {
108
+ NSObject *stale = [NSObject new];
109
+ NSObject *current = [NSObject new];
110
+ [self attachRecorder:stale];
111
+ [self attachRecorder:current];
112
+
113
+ [_bus detach:stale];
114
+ [_bus emitLifecycle:@"com.bugsee.lifecycle.Launched" reportId:nil];
115
+
116
+ XCTAssertEqual(_events.count, 1u);
117
+ }
118
+
119
+ /// The bridge owns the module; holding it here would keep a torn-down instance
120
+ /// alive for the life of the process.
121
+ - (void)testDoesNotDeliverOnceTheSinkIsDeallocated {
122
+ @autoreleasepool {
123
+ NSObject *owner = [NSObject new];
124
+ [self attachRecorder:owner];
125
+ }
126
+
127
+ [_bus emitLifecycle:@"com.bugsee.lifecycle.Launched" reportId:nil];
128
+
129
+ XCTAssertEqual(_events.count, 0u);
130
+ }
131
+
132
+ - (void)testSharedIsOneInstance {
133
+ XCTAssertTrue(BGSRNEventBus.shared == BGSRNEventBus.shared);
134
+ }
135
+
136
+ @end
@@ -0,0 +1,68 @@
1
+ @import XCTest;
2
+ @import Bugsee;
3
+ @import BugseeRNSupport;
4
+
5
+ /// Pins the iOS half of the exception-options wire shape and the backend
6
+ /// exception name contract. Mirrors the brief's case names.
7
+ @interface BGSRNExceptionsTests : XCTestCase
8
+ @end
9
+
10
+ @implementation BGSRNExceptionsTests
11
+
12
+ - (BGSRNExceptionOptions *)optionsFrom:(NSString *_Nullable)json {
13
+ NSError *error = nil;
14
+ BGSRNExceptionOptions *opts = [BGSRNExceptions loggingOptionsFromJSON:json error:&error];
15
+ XCTAssertNotNil(opts, @"rejected %@: %@", json, error);
16
+ XCTAssertNil(error);
17
+ return opts;
18
+ }
19
+
20
+ - (void)assertBad:(NSString *_Nullable)json {
21
+ NSError *error = nil;
22
+ XCTAssertNil([BGSRNExceptions loggingOptionsFromJSON:json error:&error], @"accepted %@", json);
23
+ XCTAssertNotNil(error, @"no error for %@", json);
24
+ XCTAssertEqualObjects(error.domain, BGSRNExceptionsErrorDomain);
25
+ }
26
+
27
+ - (void)testTheNameIsTheBackendContract {
28
+ XCTAssertEqualObjects(BGSRNReactNativeExceptionName, @"ReactNativeWebException");
29
+ }
30
+
31
+ - (void)testDomainIsKept {
32
+ BGSRNExceptionOptions *opts = [self optionsFrom:@"{\"domain\":\"auth\"}"];
33
+ XCTAssertEqualObjects(opts.domain, @"auth");
34
+ }
35
+
36
+ - (void)testNilJsonIsNilOptions {
37
+ NSError *error = nil;
38
+ XCTAssertNil([BGSRNExceptions loggingOptionsFromJSON:nil error:&error]);
39
+ XCTAssertNil(error, @"nil text is not an error; it is no options");
40
+ }
41
+
42
+ - (void)testUnparseableJsonIsAnError {
43
+ [self assertBad:@"{\"domain\":"];
44
+ [self assertBad:@"[]"];
45
+ [self assertBad:@"\"s\""];
46
+ [self assertBad:@""];
47
+ [self assertBad:@"not json"];
48
+ }
49
+
50
+ - (void)testANonStringDomainIsAnError {
51
+ [self assertBad:@"{\"domain\":3}"];
52
+ }
53
+
54
+ - (void)testUnknownKeysAreIgnored {
55
+ BGSRNExceptionOptions *opts =
56
+ [self optionsFrom:@"{\"domain\":\"d\",\"labels\":[\"a\"],\"includeVideo\":true,\"skipFrames\":2,\"extra\":true}"];
57
+ XCTAssertEqualObjects(opts.domain, @"d");
58
+ }
59
+
60
+ /// Malformed options say so in the bridge's own words, never the system
61
+ /// parser's, which can repeat the text it choked on.
62
+ - (void)testMalformedOptionsAreTheBridgesOwnMessage {
63
+ NSError *error = nil;
64
+ XCTAssertNil([BGSRNExceptions loggingOptionsFromJSON:@"{\"domain\": \"s3cret" error:&error]);
65
+ XCTAssertEqualObjects(BGSRNErrorMessage(error), @"exception options are not a JSON object: malformed JSON");
66
+ }
67
+
68
+ @end
@@ -0,0 +1,41 @@
1
+ @import Foundation;
2
+ @import Bugsee;
3
+
4
+ NS_ASSUME_NONNULL_BEGIN
5
+
6
+ /// A `BGSReportContract` that holds the state the bridge reads and writes, and
7
+ /// records every MUTATING call by selector, in order -- so a test can assert
8
+ /// HOW the report was changed (`replaceLabels:` rather than `clearLabels` +
9
+ /// `addLabels:`), not only its end state.
10
+ ///
11
+ /// A method this fake does not model raises, so a test cannot pass by
12
+ /// accident through a call the bridge was never meant to make.
13
+ ///
14
+ /// The severity setter behaves like the SDK's: it ignores anything outside
15
+ /// 1..5 and keeps the current value. That is the silent refusal the bridge's
16
+ /// own validation exists to turn into a rejection.
17
+ @interface BGSRNFakeReport : NSObject <BGSReportContract>
18
+
19
+ @property (nonatomic, copy) NSString *fakeReportId;
20
+ @property (nonatomic, copy) NSString *fakeType;
21
+ @property (nonatomic, copy, nullable) NSString *fakeSummary;
22
+ @property (nonatomic, copy, nullable) NSString *fakeDescription;
23
+ @property (nonatomic) BugseeSeverityLevel fakeSeverity;
24
+ @property (nonatomic, readonly) NSMutableArray<NSString *> *fakeLabels;
25
+ @property (nonatomic, readonly) NSMutableDictionary<NSString *, id> *fakeAttributes;
26
+ @property (nonatomic, copy) NSArray<NSNumber *> *fakeScreenshotDisplayIds;
27
+ @property (nonatomic, readonly) NSMutableArray<NSString *> *fakeAttachmentNames;
28
+
29
+ /// When set, both attachment methods return nil, as the SDK does.
30
+ @property (nonatomic) BOOL rejectAttachments;
31
+
32
+ /// Every mutating selector called, in order.
33
+ @property (nonatomic, readonly) NSMutableArray<NSString *> *mutations;
34
+ /// `@[path, name, mimeType or NSNull, @(move)]` of the last file attachment.
35
+ @property (nonatomic, copy, nullable) NSArray *lastFileAttachment;
36
+ /// `@[data, name, mimeType or NSNull]` of the last data attachment.
37
+ @property (nonatomic, copy, nullable) NSArray *lastDataAttachment;
38
+
39
+ @end
40
+
41
+ NS_ASSUME_NONNULL_END
@@ -0,0 +1,166 @@
1
+ #import "BGSRNFakeReport.h"
2
+
3
+ /// An attachment carrying only what the bridge reads: its name.
4
+ @interface BGSRNFakeAttachment : NSObject <BGSAttachmentContract>
5
+ @end
6
+
7
+ @implementation BGSRNFakeAttachment
8
+ @synthesize name = _name;
9
+ @synthesize mimeType = _mimeType;
10
+ @synthesize fileName = _fileName;
11
+ @synthesize filePath = _filePath;
12
+ @synthesize data = _data;
13
+
14
+ - (void)deleteFile {
15
+ [NSException raise:NSInternalInconsistencyException format:@"BGSRNFakeAttachment does not model deleteFile"];
16
+ }
17
+
18
+ - (void)deleteFileAsync:(void (^)(BOOL))completion {
19
+ [NSException raise:NSInternalInconsistencyException format:@"BGSRNFakeAttachment does not model deleteFileAsync:"];
20
+ }
21
+ @end
22
+
23
+ static void Unmodeled(SEL selector) {
24
+ [NSException raise:NSInternalInconsistencyException
25
+ format:@"BGSRNFakeReport does not model %@", NSStringFromSelector(selector)];
26
+ }
27
+
28
+ @implementation BGSRNFakeReport
29
+
30
+ - (instancetype)init {
31
+ self = [super init];
32
+ if (self) {
33
+ _fakeReportId = @"report-1";
34
+ _fakeType = @"bug";
35
+ _fakeLabels = [NSMutableArray array];
36
+ _fakeAttributes = [NSMutableDictionary dictionary];
37
+ _fakeScreenshotDisplayIds = @[];
38
+ _fakeAttachmentNames = [NSMutableArray array];
39
+ _mutations = [NSMutableArray array];
40
+ }
41
+ return self;
42
+ }
43
+
44
+ - (void)record:(SEL)selector {
45
+ [_mutations addObject:NSStringFromSelector(selector)];
46
+ }
47
+
48
+ #pragma mark - Modelled
49
+
50
+ - (NSString *)reportId { return _fakeReportId; }
51
+ - (NSString *)type { return _fakeType; }
52
+
53
+ - (NSString *)summary { return _fakeSummary; }
54
+ - (void)setSummary:(NSString *)summary {
55
+ [self record:_cmd];
56
+ _fakeSummary = [summary copy];
57
+ }
58
+
59
+ - (NSString *)reportDescription { return _fakeDescription; }
60
+ - (void)setReportDescription:(NSString *)reportDescription {
61
+ [self record:_cmd];
62
+ _fakeDescription = [reportDescription copy];
63
+ }
64
+
65
+ - (BugseeSeverityLevel)severity { return _fakeSeverity; }
66
+ - (void)setSeverity:(BugseeSeverityLevel)severity {
67
+ [self record:_cmd];
68
+ // The SDK's own refusal: out of range keeps the current value, silently.
69
+ if (severity >= BugseeSeverityLow && severity <= BugseeSeverityBlocker) {
70
+ _fakeSeverity = severity;
71
+ }
72
+ }
73
+
74
+ - (NSMutableArray<NSString *> *)labels { return [_fakeLabels mutableCopy]; }
75
+ - (void)addLabel:(NSString *)label {
76
+ [self record:_cmd];
77
+ [_fakeLabels addObject:label];
78
+ }
79
+ - (void)addLabels:(NSArray<NSString *> *)labels {
80
+ [self record:_cmd];
81
+ [_fakeLabels addObjectsFromArray:labels];
82
+ }
83
+ - (void)clearLabels {
84
+ [self record:_cmd];
85
+ [_fakeLabels removeAllObjects];
86
+ }
87
+ - (void)replaceLabels:(NSArray<NSString *> *)labels {
88
+ [self record:_cmd];
89
+ [_fakeLabels setArray:labels];
90
+ }
91
+
92
+ - (NSMutableDictionary<NSString *, id> *)attributes { return [_fakeAttributes mutableCopy]; }
93
+ - (id)attributeForName:(NSString *)name { return _fakeAttributes[name]; }
94
+ - (void)setAttribute:(id)value forName:(NSString *)name {
95
+ [self record:_cmd];
96
+ _fakeAttributes[name] = value;
97
+ }
98
+ - (void)removeAttributeForName:(NSString *)name {
99
+ [self record:_cmd];
100
+ [_fakeAttributes removeObjectForKey:name];
101
+ }
102
+ - (void)clearAllAttributes {
103
+ [self record:_cmd];
104
+ [_fakeAttributes removeAllObjects];
105
+ }
106
+
107
+ - (NSArray<NSNumber *> *)screenshotDisplayIds { return _fakeScreenshotDisplayIds; }
108
+
109
+ - (NSMutableArray<id<BGSAttachmentContract>> *)attachments {
110
+ NSMutableArray *result = [NSMutableArray array];
111
+ for (NSString *name in _fakeAttachmentNames) {
112
+ BGSRNFakeAttachment *attachment = [BGSRNFakeAttachment new];
113
+ attachment.name = name;
114
+ [result addObject:attachment];
115
+ }
116
+ return result;
117
+ }
118
+
119
+ - (id<BGSAttachmentContract>)addAttachmentWithFilePath:(NSString *)filePath
120
+ name:(NSString *)name
121
+ mimeType:(NSString *)mimeType
122
+ move:(BOOL)move {
123
+ [self record:_cmd];
124
+ self.lastFileAttachment = @[ filePath, name, mimeType ?: (id)NSNull.null, @(move) ];
125
+ return [self added:name];
126
+ }
127
+
128
+ - (id<BGSAttachmentContract>)addAttachmentWithData:(NSData *)data
129
+ name:(NSString *)name
130
+ mimeType:(NSString *)mimeType {
131
+ [self record:_cmd];
132
+ self.lastDataAttachment = @[ data, name, mimeType ?: (id)NSNull.null ];
133
+ return [self added:name];
134
+ }
135
+
136
+ - (id<BGSAttachmentContract>)added:(NSString *)name {
137
+ if (_rejectAttachments) {
138
+ return nil;
139
+ }
140
+ [_fakeAttachmentNames addObject:name];
141
+ BGSRNFakeAttachment *attachment = [BGSRNFakeAttachment new];
142
+ attachment.name = name;
143
+ return attachment;
144
+ }
145
+
146
+ #pragma mark - Not modelled
147
+
148
+ - (NSString *)email { Unmodeled(_cmd); return nil; }
149
+ - (void)setEmail:(NSString *)email { Unmodeled(_cmd); }
150
+ - (id<BGSAttachmentContract>)createAndAddAttachmentWithName:(NSString *)name { Unmodeled(_cmd); return nil; }
151
+ - (void)addAttachment:(id<BGSAttachmentContract>)attachment { Unmodeled(_cmd); }
152
+ - (void)clearAttachments { Unmodeled(_cmd); }
153
+ - (void)getScreenshotForDisplayId:(NSInteger)displayId completion:(void (^)(UIImage *))completion { Unmodeled(_cmd); }
154
+ - (void)enumerateScreenshots:(void (^)(NSInteger, UIImage *))callback blockAndWait:(BOOL)blockAndWait { Unmodeled(_cmd); }
155
+ - (void)releaseScreenshotBitmaps { Unmodeled(_cmd); }
156
+ - (void)setScreenshot:(UIImage *)screenshot displayId:(NSInteger)displayId annotated:(BOOL)annotated completion:(BGSCallback)completion { Unmodeled(_cmd); }
157
+ - (void)setScreenshot:(UIImage *)screenshot displayId:(NSInteger)displayId { Unmodeled(_cmd); }
158
+ - (void)setScreenshot:(UIImage *)screenshot displayId:(NSInteger)displayId completion:(BGSCallback)completion { Unmodeled(_cmd); }
159
+ - (void)setScreenshot:(UIImage *)screenshot displayId:(NSInteger)displayId annotated:(BOOL)annotated { Unmodeled(_cmd); }
160
+ - (NSDictionary<NSString *, id> *)screenshotAttributesForDisplayId:(NSInteger)displayId { Unmodeled(_cmd); return nil; }
161
+ - (BOOL)isScreenshotChanged { Unmodeled(_cmd); return NO; }
162
+ - (void)updateFromReport:(id<BGSReportContract>)report { Unmodeled(_cmd); }
163
+ - (void)updateFromReport:(id<BGSReportContract>)report completion:(BGSCallback)completion { Unmodeled(_cmd); }
164
+ - (void)exportVideoToPath:(NSString *)exportPath completion:(void (^)(NSArray<NSString *> *))completion { Unmodeled(_cmd); }
165
+
166
+ @end
@@ -0,0 +1,85 @@
1
+ // Not `@import`: this file is Objective-C++, and neither delivery path turns
2
+ // on C++ modules -- see BugseeModule.mm for the same note.
3
+ #import <XCTest/XCTest.h>
4
+ #import "BGSRNGuardedEmit.h"
5
+
6
+ #include <functional>
7
+
8
+ /// The defect this guards: the codegen `emitOn*` call is backed by a
9
+ /// `std::function` that is unset until the TurboModule's JSI object is built.
10
+ /// Calling an unset one throws `std::bad_function_call`, a C++ exception that
11
+ /// Objective-C's `@catch (NSException *)` cannot see -- left unguarded it
12
+ /// unwinds straight through to `std::terminate`.
13
+ ///
14
+ /// `std::function<void()>` stands in for the codegen emitter here: this
15
+ /// package has no TurboModule spec of its own to build a real one against,
16
+ /// and an unset `std::function` throws the identical exception a real unset
17
+ /// emitter does.
18
+ @interface BGSRNGuardedEmitTests : XCTestCase
19
+ @end
20
+
21
+ @implementation BGSRNGuardedEmitTests
22
+
23
+ - (void)testEmitBeforeEmitterIsSetReturnsNoWithoutThrowingAndIsDropped {
24
+ std::function<void()> unset;
25
+ __block BOOL delivered = NO;
26
+ __block BOOL result = YES;
27
+
28
+ // The guard catches INSIDE this Objective-C++ file and reports the drop as
29
+ // NO. Nothing may unwind out of it: its callers are plain Objective-C,
30
+ // compiled without -fobjc-arc-exceptions, where an exception passing
31
+ // through a frame leaks every strong local in it.
32
+ XCTAssertNoThrow(result = BGSRNGuardedEmit(^{
33
+ unset();
34
+ delivered = YES;
35
+ }, @"onLifecycleEvent"));
36
+
37
+ XCTAssertFalse(result, @"an emit through an unset emitter must report failure");
38
+ XCTAssertFalse(delivered, @"an emit through an unset emitter must be dropped, not delivered");
39
+ }
40
+
41
+ /// Not every C++ throw is a `std::exception`: a JSI or codegen path can throw
42
+ /// anything, and a `catch (const std::exception &)` alone lets the rest
43
+ /// unwind to `std::terminate`.
44
+ - (void)testANonStdExceptionIsGuardedToo {
45
+ __block BOOL result = YES;
46
+
47
+ XCTAssertNoThrow(result = BGSRNGuardedEmit(^{
48
+ throw 42;
49
+ }, @"onReportHandlerRequest"));
50
+
51
+ XCTAssertFalse(result);
52
+ }
53
+
54
+ /// An Objective-C exception from the emit (a payload that cannot convert)
55
+ /// must not unwind into the Objective-C caller either.
56
+ - (void)testAnNSExceptionIsGuarded {
57
+ __block BOOL result = YES;
58
+
59
+ XCTAssertNoThrow(result = BGSRNGuardedEmit(^{
60
+ [NSException raise:NSInvalidArgumentException format:@"cannot convert"];
61
+ }, @"onLifecycleEvent"));
62
+
63
+ XCTAssertFalse(result);
64
+ }
65
+
66
+ - (void)testEmitAfterEmitterIsSetDeliversAndReturnsYes {
67
+ std::function<void()> set = [] {
68
+ };
69
+ __block BOOL delivered = NO;
70
+ __block BOOL result = NO;
71
+
72
+ XCTAssertNoThrow(result = BGSRNGuardedEmit(^{
73
+ set();
74
+ delivered = YES;
75
+ }, @"onLifecycleEvent"));
76
+
77
+ XCTAssertTrue(result);
78
+ XCTAssertTrue(delivered, @"an emit through a set emitter must be delivered");
79
+ }
80
+
81
+ - (void)testNoEmitIsNotADelivery {
82
+ XCTAssertFalse(BGSRNGuardedEmit(nil, @"onLifecycleEvent"));
83
+ }
84
+
85
+ @end