@@ -239,6 +239,82 @@ - (void)testCreateOptionsWithDictionarySpotlightZero
239239 XCTAssertFalse (actualOptions.enableSpotlight , @" Did not disable spotlight" );
240240}
241241
242+ - (void )testCreateOptionsWithDictionaryEnableUnhandledCPPExceptionsV2Enabled
243+ {
244+ RNSentry *rnSentry = [[RNSentry alloc ] init ];
245+ NSError *error = nil ;
246+
247+ NSDictionary *_Nonnull mockedReactNativeDictionary = @{
248+ @" dsn" :
@" https://[email protected] /123456" ,
249+ @" _experiments" : @ {
250+ @" enableUnhandledCPPExceptionsV2" : @YES ,
251+ },
252+ };
253+ SentryOptions *actualOptions = [rnSentry createOptionsWithDictionary: mockedReactNativeDictionary
254+ error: &error];
255+
256+ XCTAssertNotNil (actualOptions, @" Did not create sentry options" );
257+ XCTAssertNil (error, @" Should not pass no error" );
258+
259+ id experimentalOptions = [actualOptions valueForKey: @" experimental" ];
260+ XCTAssertNotNil (experimentalOptions, @" Experimental options should not be nil" );
261+
262+ BOOL enableUnhandledCPPExceptions =
263+ [[experimentalOptions valueForKey: @" enableUnhandledCPPExceptionsV2" ] boolValue ];
264+ XCTAssertTrue (
265+ enableUnhandledCPPExceptions, @" enableUnhandledCPPExceptionsV2 should be enabled" );
266+ }
267+
268+ - (void )testCreateOptionsWithDictionaryEnableUnhandledCPPExceptionsV2Disabled
269+ {
270+ RNSentry *rnSentry = [[RNSentry alloc ] init ];
271+ NSError *error = nil ;
272+
273+ NSDictionary *_Nonnull mockedReactNativeDictionary = @{
274+ @" dsn" :
@" https://[email protected] /123456" ,
275+ @" _experiments" : @ {
276+ @" enableUnhandledCPPExceptionsV2" : @NO ,
277+ },
278+ };
279+ SentryOptions *actualOptions = [rnSentry createOptionsWithDictionary: mockedReactNativeDictionary
280+ error: &error];
281+
282+ XCTAssertNotNil (actualOptions, @" Did not create sentry options" );
283+ XCTAssertNil (error, @" Should not pass no error" );
284+
285+ id experimentalOptions = [actualOptions valueForKey: @" experimental" ];
286+ XCTAssertNotNil (experimentalOptions, @" Experimental options should not be nil" );
287+
288+ BOOL enableUnhandledCPPExceptions =
289+ [[experimentalOptions valueForKey: @" enableUnhandledCPPExceptionsV2" ] boolValue ];
290+ XCTAssertFalse (
291+ enableUnhandledCPPExceptions, @" enableUnhandledCPPExceptionsV2 should be disabled" );
292+ }
293+
294+ - (void )testCreateOptionsWithDictionaryEnableUnhandledCPPExceptionsV2Default
295+ {
296+ RNSentry *rnSentry = [[RNSentry alloc ] init ];
297+ NSError *error = nil ;
298+
299+ NSDictionary *_Nonnull mockedReactNativeDictionary = @{
300+ @" dsn" :
@" https://[email protected] /123456" ,
301+ };
302+ SentryOptions *actualOptions = [rnSentry createOptionsWithDictionary: mockedReactNativeDictionary
303+ error: &error];
304+
305+ XCTAssertNotNil (actualOptions, @" Did not create sentry options" );
306+ XCTAssertNil (error, @" Should not pass no error" );
307+
308+ // Test that when no _experiments are provided, the experimental option defaults to false
309+ id experimentalOptions = [actualOptions valueForKey: @" experimental" ];
310+ XCTAssertNotNil (experimentalOptions, @" Experimental options should not be nil" );
311+
312+ BOOL enableUnhandledCPPExceptions =
313+ [[experimentalOptions valueForKey: @" enableUnhandledCPPExceptionsV2" ] boolValue ];
314+ XCTAssertFalse (
315+ enableUnhandledCPPExceptions, @" enableUnhandledCPPExceptionsV2 should default to disabled" );
316+ }
317+
242318- (void )testPassesErrorOnWrongDsn
243319{
244320 RNSentry *rnSentry = [[RNSentry alloc ] init ];
0 commit comments