-
Notifications
You must be signed in to change notification settings - Fork 24.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Convert the last Unit Tests to Kotlin (#42078)
Summary: Pull Request resolved: #42078 Resubmit of D51891716 and D52033328 I'm doing a pass and converting the last Java Unit Tests we had to Kotlin I've also re-enabled multiple tests that were disabled in the past. Changelog: [Internal] [Changed] - Convert the last Unit Tests to Kotlin Reviewed By: rshest Differential Revision: D52430728 fbshipit-source-id: e6b4a6ed88d852024d959cf5148e992e97a84434
- Loading branch information
1 parent
ac9b87c
commit c75abef
Showing
8 changed files
with
505 additions
and
535 deletions.
There are no files selected for viewing
71 changes: 0 additions & 71 deletions
71
...ive/ReactAndroid/src/test/java/com/facebook/react/runtime/BridgelessReactContextTest.java
This file was deleted.
Oops, something went wrong.
70 changes: 70 additions & 0 deletions
70
...ative/ReactAndroid/src/test/java/com/facebook/react/runtime/BridgelessReactContextTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/* | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
package com.facebook.react.runtime | ||
|
||
import android.app.Activity | ||
import android.content.Context | ||
import com.facebook.react.bridge.JSIModuleType | ||
import com.facebook.react.fabric.FabricUIManager | ||
import com.facebook.react.uimanager.UIManagerModule | ||
import com.facebook.testutils.shadows.ShadowSoLoader | ||
import org.assertj.core.api.Assertions | ||
import org.junit.Before | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
import org.mockito.ArgumentMatchers | ||
import org.mockito.Mockito | ||
import org.mockito.Mockito.doReturn | ||
import org.robolectric.Robolectric | ||
import org.robolectric.RobolectricTestRunner | ||
import org.robolectric.annotation.Config | ||
|
||
/** Tests [BridgelessReactContext] */ | ||
@RunWith(RobolectricTestRunner::class) | ||
@Config(shadows = [ShadowSoLoader::class]) | ||
class BridgelessReactContextTest { | ||
private lateinit var context: Context | ||
private lateinit var reactHost: ReactHostImpl | ||
private lateinit var bridgelessReactContext: BridgelessReactContext | ||
|
||
@Before | ||
fun setUp() { | ||
context = Robolectric.buildActivity(Activity::class.java).create().get() | ||
reactHost = Mockito.mock(ReactHostImpl::class.java) | ||
bridgelessReactContext = BridgelessReactContext(context, reactHost) | ||
} | ||
|
||
@Test | ||
fun getNativeModuleTest() { | ||
val mUiManagerModule = Mockito.mock(UIManagerModule::class.java) | ||
doReturn(mUiManagerModule) | ||
.`when`(reactHost) | ||
.getNativeModule(ArgumentMatchers.any<Class<UIManagerModule>>()) | ||
val uiManagerModule = bridgelessReactContext.getNativeModule(UIManagerModule::class.java) | ||
Assertions.assertThat(uiManagerModule).isEqualTo(mUiManagerModule) | ||
} | ||
|
||
@Test(expected = UnsupportedOperationException::class) | ||
fun getJSIModule_throwsException() { | ||
bridgelessReactContext.getJSIModule(JSIModuleType.TurboModuleManager) | ||
} | ||
|
||
@Test | ||
fun getJSIModuleTest() { | ||
val fabricUiManager = Mockito.mock(FabricUIManager::class.java) | ||
doReturn(fabricUiManager).`when`(reactHost).uiManager | ||
Assertions.assertThat(bridgelessReactContext.getJSIModule(JSIModuleType.UIManager)) | ||
.isEqualTo(fabricUiManager) | ||
} | ||
|
||
@Test(expected = UnsupportedOperationException::class) | ||
fun getCatalystInstance_throwsException() { | ||
// Disable this test for now due to mocking FabricUIManager fails | ||
bridgelessReactContext.catalystInstance | ||
} | ||
} |
187 changes: 0 additions & 187 deletions
187
...ges/react-native/ReactAndroid/src/test/java/com/facebook/react/runtime/ReactHostTest.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.