package com.contentsquare.rn.csq.masking import com.facebook.react.uimanager.ThemedReactContext import com.facebook.react.uimanager.ViewGroupManager import io.mockk.mockk import org.junit.Assert.assertEquals import org.junit.Assert.assertNotNull import org.junit.Assert.assertTrue import org.junit.Before import org.junit.Test class CSQUnmaskedViewManagerTest { private lateinit var underTest: CSQUnmaskedViewManager private lateinit var mockReactContext: ThemedReactContext @Before fun setup() { underTest = CSQUnmaskedViewManager() mockReactContext = mockk(relaxed = true) } @Test fun `REACT_CLASS companion object should have correct value`() { // Given - setup already done // When val reactClass = CSQUnmaskedViewManager.REACT_CLASS // Then assertEquals("REACT_CLASS should be CSQUnmaskedView", "CSQUnmaskedView", reactClass) } @Test fun `createViewInstance should create new instance each time using reflection`() { // Given - setup already done // When val createViewInstanceMethod = underTest::class.java.getDeclaredMethod( "createViewInstance", ThemedReactContext::class.java ) createViewInstanceMethod.isAccessible = true val viewInstance1 = createViewInstanceMethod.invoke(underTest, mockReactContext) val viewInstance2 = createViewInstanceMethod.invoke(underTest, mockReactContext) // Then assertNotNull("First view instance should not be null", viewInstance1) assertNotNull("Second view instance should not be null", viewInstance2) assertTrue("Should create different instances", viewInstance1 !== viewInstance2) assertTrue("Both should be CSQUnmaskedView instances", viewInstance1 is CSQUnmaskedView) assertTrue("Both should be CSQUnmaskedView instances", viewInstance2 is CSQUnmaskedView) } }