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 CSQMaskedViewManagerTest { private lateinit var underTest: CSQMaskedViewManager private lateinit var mockReactContext: ThemedReactContext @Before fun setup() { underTest = CSQMaskedViewManager() mockReactContext = mockk(relaxed = true) } @Test fun `REACT_CLASS companion object should have correct value`() { // Given - setup already done // When val reactClass = CSQMaskedViewManager.REACT_CLASS // Then assertEquals("REACT_CLASS should be CSQMaskedView", "CSQMaskedView", 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 CSQMaskedView instances", viewInstance1 is CSQMaskedView) assertTrue("Both should be CSQMaskedView instances", viewInstance2 is CSQMaskedView) } }