-
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 ReactPropForShadowNodeSpecTest to Kotlin (#39284)
Summary: This PR converts ReactPropForShadowNodeSpecTest to Kotlin. #38825 ## Changelog: [INTERNAL] [CHANGED] - Kotlinify ReactPropForShadowNodeSpecTest.java For more details, see: https://reactnative.dev/contributing/changelogs-in-pull-requests Pull Request resolved: #39284 Test Plan: `./gradlew :packages:react-native:ReactAndroid:test` must pass Reviewed By: javache Differential Revision: D48960815 Pulled By: rshest fbshipit-source-id: d66ab64373e300c5fff6fa2013faac473890804c
- Loading branch information
1 parent
1e2af65
commit 8973978
Showing
2 changed files
with
105 additions
and
118 deletions.
There are no files selected for viewing
118 changes: 0 additions & 118 deletions
118
...actAndroid/src/test/java/com/facebook/react/uimanager/ReactPropForShadowNodeSpecTest.java
This file was deleted.
Oops, something went wrong.
105 changes: 105 additions & 0 deletions
105
...ReactAndroid/src/test/java/com/facebook/react/uimanager/ReactPropForShadowNodeSpecTest.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,105 @@ | ||
/* | ||
* 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.uimanager | ||
|
||
import android.view.View | ||
import com.facebook.react.uimanager.annotations.ReactProp | ||
import com.facebook.react.uimanager.annotations.ReactPropGroup | ||
import org.junit.Ignore | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
import org.robolectric.RobolectricTestRunner | ||
|
||
/** | ||
* Test that verifies that spec of methods annotated with @ReactProp in {@link ReactShadowNode} is | ||
* correct | ||
*/ | ||
@RunWith(RobolectricTestRunner::class) | ||
@Ignore | ||
class ReactPropForShadowNodeSpecTest { | ||
@Test(expected = RuntimeException::class) | ||
fun testMethodWithWrongNumberOfParams() { | ||
BaseViewManager( | ||
object : ReactShadowNodeImpl() { | ||
@ReactProp(name = "prop") | ||
fun setterWithIncorrectNumberOfArgs(value: Boolean, anotherValue: Int) {} | ||
} | ||
.javaClass) | ||
.nativeProps | ||
} | ||
|
||
@Test(expected = RuntimeException::class) | ||
fun testMethodWithTooFewParams() { | ||
BaseViewManager( | ||
object : ReactShadowNodeImpl() { | ||
@ReactProp(name = "prop") fun setterWithNoArgs() {} | ||
} | ||
.javaClass) | ||
.nativeProps | ||
} | ||
|
||
@Test(expected = RuntimeException::class) | ||
fun testUnsupportedValueType() { | ||
BaseViewManager( | ||
object : ReactShadowNodeImpl() { | ||
@ReactProp(name = "prop") fun setterWithMap(value: Map<*, *>) {} | ||
} | ||
.javaClass) | ||
.nativeProps | ||
} | ||
|
||
@Test(expected = RuntimeException::class) | ||
fun testGroupInvalidNumberOfParams() { | ||
BaseViewManager( | ||
object : ReactShadowNodeImpl() { | ||
@ReactPropGroup(names = ["prop1", "prop2"]) | ||
fun setterWithTooManyParams(index: Int, value: Float, boolean: Boolean) {} | ||
} | ||
.javaClass) | ||
.nativeProps | ||
} | ||
|
||
@Test(expected = RuntimeException::class) | ||
fun testGroupTooFewParams() { | ||
BaseViewManager( | ||
object : ReactShadowNodeImpl() { | ||
@ReactPropGroup(names = ["props1", "prop2"]) | ||
fun setterWithTooFewParams(index: Int) {} | ||
} | ||
.javaClass) | ||
.nativeProps | ||
} | ||
|
||
@Test(expected = RuntimeException::class) | ||
fun testGroupNoIndexParam() { | ||
BaseViewManager( | ||
object : ReactShadowNodeImpl() { | ||
@ReactPropGroup(names = ["prop1", "prop2"]) | ||
fun setterWithNoIndexParam(value: Float, boolean: Boolean) {} | ||
} | ||
.javaClass) | ||
.nativeProps | ||
} | ||
|
||
companion object { | ||
private class BaseViewManager( | ||
private val shadowNodeClass: Class<out ReactShadowNode<ReactShadowNodeImpl>> | ||
) : ViewManager<View, ReactShadowNode<*>>() { | ||
override fun getName(): String = "IgnoredName" | ||
|
||
override fun createShadowNodeInstance(): ReactShadowNode<*>? = null | ||
|
||
override fun getShadowNodeClass(): Class<out ReactShadowNode<ReactShadowNodeImpl>> = | ||
shadowNodeClass | ||
|
||
override fun createViewInstance(reactContext: ThemedReactContext): View = View(null) | ||
|
||
override fun updateExtraData(root: View, extraData: Any?) {} | ||
} | ||
} | ||
} |