Skip to content

Commit

Permalink
Add test for InterpolatorType
Browse files Browse the repository at this point in the history
Summary: Adding a test for the newly added InterpolatorType.fromString()

Reviewed By: axe-fb

Differential Revision: D10203814

fbshipit-source-id: f3c70db1a5754c79b1bdd881d266bec110934494
  • Loading branch information
Emily Janzer authored and facebook-github-bot committed Oct 8, 2018
1 parent 31d6a69 commit b7526b2
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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 = ["[email protected]"],
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"),
],
)
Original file line number Diff line number Diff line change
@@ -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");
}
}

0 comments on commit b7526b2

Please sign in to comment.