Convert JavaOnlyArrayTest to Kotlin (#37855)

Summary:
Part of https://github.com/facebook/react-native/issues/37708

## Changelog:
[Internal] [Changed] - Convert JavaOnlyArrayTest to Kotlin

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

Reviewed By: cortinico

Differential Revision: D46697501

Pulled By: rshest

fbshipit-source-id: edc3906c41af4936eacdeb95502cc62f80ae89c8
This commit is contained in:
jaroslawmichalik
2023-06-14 02:07:53 -07:00
committed by Facebook GitHub Bot
parent b03c5affdb
commit af4a0336e9
2 changed files with 29 additions and 37 deletions
@@ -1,37 +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.bridge;
import static org.assertj.core.api.Assertions.assertThat;
import org.junit.Test;
/** Tests for {@link JavaOnlyArray} */
public class JavaOnlyArrayTest {
@Test
public void testGetType() throws Exception {
JavaOnlyArray values =
JavaOnlyArray.of(1, 2f, 3., "4", false, JavaOnlyArray.of(), JavaOnlyMap.of(), null);
ReadableType[] expectedTypes =
new ReadableType[] {
ReadableType.Number,
ReadableType.Number,
ReadableType.Number,
ReadableType.String,
ReadableType.Boolean,
ReadableType.Array,
ReadableType.Map,
ReadableType.Null
};
for (int i = 0; i < values.size(); i++) {
assertThat(values.getType(i)).isEqualTo(expectedTypes[i]);
}
}
}
@@ -0,0 +1,29 @@
/*
* 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.bridge
import org.assertj.core.api.Assertions.assertThat
import org.junit.Test
/** Tests for [JavaOnlyArray] */
class JavaOnlyArrayTest {
@Test
fun testGetType() {
val values =
JavaOnlyArray.of(1, 2f, 3.0, "4", false, JavaOnlyArray.of(), JavaOnlyMap.of(), null)
assertThat(values.getType(0)).isEqualTo(ReadableType.Number)
assertThat(values.getType(1)).isEqualTo(ReadableType.Number)
assertThat(values.getType(2)).isEqualTo(ReadableType.Number)
assertThat(values.getType(3)).isEqualTo(ReadableType.String)
assertThat(values.getType(4)).isEqualTo(ReadableType.Boolean)
assertThat(values.getType(5)).isEqualTo(ReadableType.Array)
assertThat(values.getType(6)).isEqualTo(ReadableType.Map)
assertThat(values.getType(7)).isEqualTo(ReadableType.Null)
}
}