@@ -5,9 +5,13 @@ import com.facebook.react.bridge.JavaOnlyMap
5
5
import com.facebook.react.common.JavascriptException
6
6
import io.sentry.Breadcrumb
7
7
import io.sentry.ILogger
8
+ import io.sentry.SentryEvent
9
+ import io.sentry.android.core.CurrentActivityHolder
8
10
import io.sentry.android.core.SentryAndroidOptions
11
+ import io.sentry.protocol.SdkVersion
9
12
import org.junit.Assert.assertEquals
10
13
import org.junit.Assert.assertFalse
14
+ import org.junit.Assert.assertNotNull
11
15
import org.junit.Assert.assertNull
12
16
import org.junit.Assert.assertTrue
13
17
import org.junit.Before
@@ -62,13 +66,6 @@ class RNSentryStartTest {
62
66
assertFalse(actualOptions.isEnableSpotlight)
63
67
}
64
68
65
- @Test
66
- fun `the JavascriptException is added to the ignoredExceptionsForType list on with react defaults` () {
67
- val actualOptions = SentryAndroidOptions ()
68
- RNSentryStart .updateWithReactDefaults(actualOptions, activity)
69
- assertTrue(actualOptions.ignoredExceptionsForType.contains(JavascriptException ::class .java))
70
- }
71
-
72
69
@Test
73
70
fun `beforeBreadcrumb callback filters out Sentry DSN requests breadcrumbs` () {
74
71
val options = SentryAndroidOptions ()
@@ -188,4 +185,67 @@ class RNSentryStartTest {
188
185
189
186
assertEquals(breadcrumb, result)
190
187
}
188
+
189
+ @Test
190
+ fun `the JavascriptException is added to the ignoredExceptionsForType list on with react defaults` () {
191
+ val actualOptions = SentryAndroidOptions ()
192
+ RNSentryStart .updateWithReactDefaults(actualOptions, activity)
193
+ assertTrue(actualOptions.ignoredExceptionsForType.contains(JavascriptException ::class .java))
194
+ }
195
+
196
+ @Test
197
+ fun `the sdk version information is added to the initialisation options with react defaults` () {
198
+ val actualOptions = SentryAndroidOptions ()
199
+ RNSentryStart .updateWithReactDefaults(actualOptions, activity)
200
+ assertEquals(RNSentryVersion .ANDROID_SDK_NAME , actualOptions.sdkVersion?.name)
201
+ assertEquals(
202
+ io.sentry.android.core.BuildConfig .VERSION_NAME ,
203
+ actualOptions.sdkVersion?.version,
204
+ )
205
+ assertEquals(true , actualOptions.sdkVersion?.packages?.isNotEmpty())
206
+ assertEquals(
207
+ RNSentryVersion .REACT_NATIVE_SDK_PACKAGE_NAME ,
208
+ actualOptions.sdkVersion
209
+ ?.packages
210
+ ?.last()
211
+ ?.name,
212
+ )
213
+ assertEquals(
214
+ RNSentryVersion .REACT_NATIVE_SDK_PACKAGE_VERSION ,
215
+ actualOptions.sdkVersion
216
+ ?.packages
217
+ ?.last()
218
+ ?.version,
219
+ )
220
+ }
221
+
222
+ @Test
223
+ fun `the tracing options are added to the initialisation options with react defaults` () {
224
+ val actualOptions = SentryAndroidOptions ()
225
+ RNSentryStart .updateWithReactDefaults(actualOptions, activity)
226
+ assertNull(actualOptions.tracesSampleRate)
227
+ assertNull(actualOptions.tracesSampler)
228
+ assertEquals(false , actualOptions.enableTracing)
229
+ }
230
+
231
+ @Test
232
+ fun `the current activity is added to the initialisation options with react defaults` () {
233
+ val actualOptions = SentryAndroidOptions ()
234
+ RNSentryStart .updateWithReactDefaults(actualOptions, activity)
235
+ assertEquals(activity, CurrentActivityHolder .getInstance().activity)
236
+ }
237
+
238
+ @Test
239
+ fun `beforeSend callback that sets event tags is set with react finals` () {
240
+ val options = SentryAndroidOptions ()
241
+ val event =
242
+ SentryEvent ().apply { sdk = SdkVersion (RNSentryVersion .ANDROID_SDK_NAME , " 1.0" ) }
243
+
244
+ RNSentryStart .updateWithReactFinals(options)
245
+ val result = options.beforeSend?.execute(event, mock())
246
+
247
+ assertNotNull(result)
248
+ assertEquals(" android" , result?.getTag(" event.origin" ))
249
+ assertEquals(" java" , result?.getTag(" event.environment" ))
250
+ }
191
251
}
0 commit comments