Skip to content

Commit b7526b2

Browse files
Emily Janzerfacebook-github-bot
Emily Janzer
authored andcommittedOct 8, 2018
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
1 parent 31d6a69 commit b7526b2

File tree

2 files changed

+56
-0
lines changed

2 files changed

+56
-0
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
load("//tools/build_defs/oss:rn_defs.bzl", "YOGA_TARGET", "react_native_dep", "react_native_target", "react_native_tests_target", "rn_robolectric_test")
2+
3+
rn_robolectric_test(
4+
name = "layoutanimation",
5+
srcs = glob(["**/*.java"]),
6+
contacts = ["oncall+react_native@xmail.facebook.com"],
7+
visibility = [
8+
"PUBLIC",
9+
],
10+
deps = [
11+
YOGA_TARGET,
12+
react_native_dep("third-party/java/fest:fest"),
13+
react_native_dep("third-party/java/junit:junit"),
14+
react_native_dep("third-party/java/robolectric3/robolectric:robolectric"),
15+
react_native_target("java/com/facebook/react/uimanager:uimanager"),
16+
],
17+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/**
2+
* Copyright (c) Facebook, Inc. and its affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
package com.facebook.react.uimanager.layoutanimation;
9+
10+
import com.facebook.react.uimanager.layoutanimation.InterpolatorType;
11+
import org.junit.Test;
12+
import org.junit.runner.RunWith;
13+
import org.robolectric.RobolectricTestRunner;
14+
import static org.fest.assertions.api.Assertions.assertThat;
15+
16+
@RunWith(RobolectricTestRunner.class)
17+
public class InterpolatorTypeTest {
18+
19+
@Test
20+
public void testCamelCase() {
21+
assertThat(InterpolatorType.fromString("linear")).isEqualTo(InterpolatorType.LINEAR);
22+
assertThat(InterpolatorType.fromString("easeIn")).isEqualTo(InterpolatorType.EASE_IN);
23+
assertThat(InterpolatorType.fromString("easeOut")).isEqualTo(InterpolatorType.EASE_OUT);
24+
assertThat(InterpolatorType.fromString("easeInEaseOut")).isEqualTo(InterpolatorType.EASE_IN_EASE_OUT);
25+
assertThat(InterpolatorType.fromString("spring")).isEqualTo(InterpolatorType.SPRING);
26+
}
27+
28+
@Test
29+
public void testOtherCases() {
30+
assertThat(InterpolatorType.fromString("EASEIN")).isEqualTo(InterpolatorType.EASE_IN);
31+
assertThat(InterpolatorType.fromString("easeout")).isEqualTo(InterpolatorType.EASE_OUT);
32+
assertThat(InterpolatorType.fromString("easeineaseout")).isEqualTo(InterpolatorType.EASE_IN_EASE_OUT);
33+
}
34+
35+
@Test(expected = IllegalArgumentException.class)
36+
public void testInvalidInterpolatorTypes() throws IllegalArgumentException {
37+
InterpolatorType.fromString("ease_in_ease_out");
38+
}
39+
}

0 commit comments

Comments
 (0)
Please sign in to comment.