Skip to content

Commit b953743

Browse files
authored
test: Adds unit tests for SR mask/unmask managers (#4960)
* test: Adds unit tests for SR mask/unmask managers * Add missing import
1 parent 62e4897 commit b953743

File tree

2 files changed

+78
-0
lines changed

2 files changed

+78
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package io.sentry.react.replay
2+
3+
import com.facebook.react.module.annotations.ReactModule
4+
import org.junit.Assert.assertEquals
5+
import org.junit.Assert.assertNotNull
6+
import org.junit.Before
7+
import org.junit.Test
8+
import org.junit.runner.RunWith
9+
import org.junit.runners.JUnit4
10+
import org.mockito.MockitoAnnotations
11+
12+
@RunWith(JUnit4::class)
13+
class RNSentryReplayMaskManagerTest {
14+
private val expectedName = RNSentryReplayMaskManagerImpl.REACT_CLASS
15+
16+
private lateinit var manager: RNSentryReplayMaskManager
17+
18+
@Before
19+
fun setUp() {
20+
MockitoAnnotations.openMocks(this)
21+
manager = RNSentryReplayMaskManager()
22+
}
23+
24+
@Test
25+
fun `getName returns correct react class name`() {
26+
assertEquals(expectedName, manager.getName())
27+
}
28+
29+
@Test
30+
fun `module annotation name matches getName result`() {
31+
val annotation = manager.javaClass.getAnnotation(ReactModule::class.java)
32+
assertNotNull("ReactModule annotation should be present", annotation)
33+
assertEquals(
34+
"Annotation name should match getName() result",
35+
expectedName,
36+
annotation?.name,
37+
)
38+
}
39+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package io.sentry.react.replay
2+
3+
import com.facebook.react.module.annotations.ReactModule
4+
import org.junit.Assert.assertEquals
5+
import org.junit.Assert.assertNotNull
6+
import org.junit.Before
7+
import org.junit.Test
8+
import org.junit.runner.RunWith
9+
import org.junit.runners.JUnit4
10+
import org.mockito.MockitoAnnotations
11+
12+
@RunWith(JUnit4::class)
13+
class RNSentryReplayUnmaskManagerTest {
14+
private val expectedName = RNSentryReplayUnmaskManagerImpl.REACT_CLASS
15+
16+
private lateinit var manager: RNSentryReplayUnmaskManager
17+
18+
@Before
19+
fun setUp() {
20+
MockitoAnnotations.openMocks(this)
21+
manager = RNSentryReplayUnmaskManager()
22+
}
23+
24+
@Test
25+
fun `getName returns correct react class name`() {
26+
assertEquals(expectedName, manager.getName())
27+
}
28+
29+
@Test
30+
fun `module annotation name matches getName result`() {
31+
val annotation = manager.javaClass.getAnnotation(ReactModule::class.java)
32+
assertNotNull("ReactModule annotation should be present", annotation)
33+
assertEquals(
34+
"Annotation name should match getName() result",
35+
expectedName,
36+
annotation?.name,
37+
)
38+
}
39+
}

0 commit comments

Comments
 (0)