Add test for InterpolatorType

Summary: Adding a test for the newly added InterpolatorType.fromString()

Reviewed By: axe-fb

Differential Revision: D10203814

fbshipit-source-id: f3c70db1a5754c79b1bdd881d266bec110934494
This commit is contained in:
Emily Janzer 2018-10-08 11:16:38 -07:00 committed by Facebook Github Bot
parent 31d6a69fc9
commit b7526b2095
2 changed files with 56 additions and 0 deletions

View File

@ -0,0 +1,17 @@
load("//tools/build_defs/oss:rn_defs.bzl", "YOGA_TARGET", "react_native_dep", "react_native_target", "react_native_tests_target", "rn_robolectric_test")
rn_robolectric_test(
name = "layoutanimation",
srcs = glob(["**/*.java"]),
contacts = ["oncall+react_native@xmail.facebook.com"],
visibility = [
"PUBLIC",
],
deps = [
YOGA_TARGET,
react_native_dep("third-party/java/fest:fest"),
react_native_dep("third-party/java/junit:junit"),
react_native_dep("third-party/java/robolectric3/robolectric:robolectric"),
react_native_target("java/com/facebook/react/uimanager:uimanager"),
],
)

View File

@ -0,0 +1,39 @@
/**
* Copyright (c) Facebook, Inc. and its 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 com.facebook.react.uimanager.layoutanimation.InterpolatorType;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import static org.fest.assertions.api.Assertions.assertThat;
@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(expected = IllegalArgumentException.class)
public void testInvalidInterpolatorTypes() throws IllegalArgumentException {
InterpolatorType.fromString("ease_in_ease_out");
}
}