Convert InterpolatorTypeTest to Kotlin (#37724)

Summary:
Converts InterpolatorTypeTest from Java to Kotlin, as per issue https://github.com/facebook/react-native/issues/37708

## Changelog:

[Internal] [Changed] - Convert InterpolatorTypeTest to Kotlin

<!-- Help reviewers and the release process by writing your own changelog entry.

Pick one each for the category and type tags:

[ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message

For more details, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests

Pull Request resolved: https://github.com/facebook/react-native/pull/37724

Test Plan:
Tests pass: `./gradlew :packages:react-native:ReactAndroid:test`
Formatted with [KtFmt](https://facebook.github.io/ktfmt/)

Reviewed By: cortinico, yungsters

Differential Revision: D46486141

Pulled By: mdvacca

fbshipit-source-id: bcdfa6497b9170640b4b9f3f20f6afad8fb56bee
This commit is contained in:
Jan Jiménez Serra
2023-06-07 13:31:11 -07:00
committed by Facebook GitHub Bot
parent 4002a251a5
commit 84200fe9f5
2 changed files with 48 additions and 49 deletions
@@ -1,49 +0,0 @@
/*
* 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.layoutanimation;
import static org.assertj.core.api.Assertions.assertThat;
import java.util.Locale;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
@RunWith(RobolectricTestRunner.class)
public class InterpolatorTypeTest {
@Test
public void testCamelCase() {
assertThat(InterpolatorType.fromString("linear")).isEqualTo(InterpolatorType.LINEAR);
assertThat(InterpolatorType.fromString("easeIn")).isEqualTo(InterpolatorType.EASE_IN);
assertThat(InterpolatorType.fromString("easeOut")).isEqualTo(InterpolatorType.EASE_OUT);
assertThat(InterpolatorType.fromString("easeInEaseOut"))
.isEqualTo(InterpolatorType.EASE_IN_EASE_OUT);
assertThat(InterpolatorType.fromString("spring")).isEqualTo(InterpolatorType.SPRING);
}
@Test
public void testOtherCases() {
assertThat(InterpolatorType.fromString("EASEIN")).isEqualTo(InterpolatorType.EASE_IN);
assertThat(InterpolatorType.fromString("easeout")).isEqualTo(InterpolatorType.EASE_OUT);
assertThat(InterpolatorType.fromString("easeineaseout"))
.isEqualTo(InterpolatorType.EASE_IN_EASE_OUT);
}
@Test
public void testLocales() {
Locale.setDefault(Locale.forLanguageTag("tr-TR"));
assertThat(InterpolatorType.fromString("easeInEaseOut"))
.isEqualTo(InterpolatorType.EASE_IN_EASE_OUT);
}
@Test(expected = IllegalArgumentException.class)
public void testInvalidInterpolatorTypes() throws IllegalArgumentException {
InterpolatorType.fromString("ease_in_ease_out");
}
}
@@ -0,0 +1,48 @@
/*
* 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.layoutanimation
import java.util.Locale
import org.assertj.core.api.Assertions.assertThat
import org.junit.Test
import org.junit.runner.RunWith
import org.robolectric.RobolectricTestRunner
@RunWith(RobolectricTestRunner::class)
class InterpolatorTypeTest {
@Test
fun testCamelCase() {
assertThat(InterpolatorType.fromString("linear")).isEqualTo(InterpolatorType.LINEAR)
assertThat(InterpolatorType.fromString("easeIn")).isEqualTo(InterpolatorType.EASE_IN)
assertThat(InterpolatorType.fromString("easeOut")).isEqualTo(InterpolatorType.EASE_OUT)
assertThat(InterpolatorType.fromString("easeInEaseOut"))
.isEqualTo(InterpolatorType.EASE_IN_EASE_OUT)
assertThat(InterpolatorType.fromString("spring")).isEqualTo(InterpolatorType.SPRING)
}
@Test
fun testOtherCases() {
assertThat(InterpolatorType.fromString("EASEIN")).isEqualTo(InterpolatorType.EASE_IN)
assertThat(InterpolatorType.fromString("easeout")).isEqualTo(InterpolatorType.EASE_OUT)
assertThat(InterpolatorType.fromString("easeineaseout"))
.isEqualTo(InterpolatorType.EASE_IN_EASE_OUT)
}
@Test
fun testLocales() {
Locale.setDefault(Locale.forLanguageTag("tr-TR"))
assertThat(InterpolatorType.fromString("easeInEaseOut"))
.isEqualTo(InterpolatorType.EASE_IN_EASE_OUT)
}
@Test(expected = IllegalArgumentException::class)
@Throws(IllegalArgumentException::class)
fun testInvalidInterpolatorTypes() {
InterpolatorType.fromString("ease_in_ease_out")
}
}