use of com.facebook.react.bridge.JavaOnlyMap in project react-native-navigation by wix.
the class ColorParseTest method shouldParsePlatformColors.
@Test
public void shouldParsePlatformColors() throws JSONException {
JSONObject color = new JSONObject();
final JSONArray jsonArray = new JSONArray();
jsonArray.put("@color/colorPrimary");
color.put("resource_paths", jsonArray);
try (MockedStatic<Arguments> theMock = Mockito.mockStatic(Arguments.class)) {
theMock.when(Arguments::createMap).thenReturn(new JavaOnlyMap());
theMock.when(Arguments::createArray).thenReturn(new JavaOnlyArray());
assertThat(ColorParser.parse(activity, color, "color")).isInstanceOf(ReactPlatformColor.class);
}
}
use of com.facebook.react.bridge.JavaOnlyMap in project react-native-navigation by wix.
the class JSONParserTest method parsesMap.
@Test
public void parsesMap() throws Exception {
JavaOnlyMap input = new JavaOnlyMap();
input.putString("keyString", "stringValue");
input.putInt("keyInt", 123);
input.putDouble("keyDouble", 123.456);
input.putBoolean("keyBoolean", true);
input.putArray("keyArray", new JavaOnlyArray());
input.putMap("keyMap", new JavaOnlyMap());
input.putNull("bla");
JSONObject result = new JSONParser().parse(input);
assertThat(result.keys()).containsOnly("keyString", "keyInt", "keyDouble", "keyBoolean", "keyMap", "keyArray");
assertThat(result.get("keyString")).isEqualTo("stringValue");
assertThat(result.get("keyInt")).isEqualTo(123);
assertThat(result.get("keyDouble")).isEqualTo(123.456);
assertThat(result.get("keyBoolean")).isEqualTo(true);
assertThat(result.getJSONObject("keyMap").keys()).isEmpty();
assertThat(result.getJSONArray("keyArray").length()).isZero();
}
use of com.facebook.react.bridge.JavaOnlyMap in project react-native-navigation by wix.
the class JSONParserTest method parsesArrays.
@Test
public void parsesArrays() throws Exception {
JavaOnlyArray input = new JavaOnlyArray();
input.pushString("Hello");
input.pushInt(123);
input.pushDouble(123.456);
input.pushBoolean(true);
input.pushArray(new JavaOnlyArray());
input.pushMap(new JavaOnlyMap());
input.pushNull();
JSONArray result = new JSONParser().parse(input);
assertThat(result.length()).isEqualTo(6);
assertThat(result.get(0)).isEqualTo("Hello");
assertThat(result.get(1)).isEqualTo(123);
assertThat(result.get(2)).isEqualTo(123.456);
assertThat(result.get(3)).isEqualTo(true);
assertThat(result.getJSONArray(4).length()).isZero();
assertThat(result.getJSONObject(5).keys()).isEmpty();
}
use of com.facebook.react.bridge.JavaOnlyMap in project react-native-image-picker by marcshilling.
the class ImageConfigTest method defaultOptions.
private JavaOnlyMap defaultOptions() {
JavaOnlyMap options = new JavaOnlyMap();
options.putInt("maxWidth", 1000);
options.putInt("maxHeight", 600);
options.putDouble("quality", 0.5);
options.putInt("rotation", 135);
JavaOnlyMap storage = new JavaOnlyMap();
storage.putBoolean("cameraRoll", true);
options.putMap("storageOptions", storage);
return options;
}
use of com.facebook.react.bridge.JavaOnlyMap in project react-native-image-picker by marcshilling.
the class ImagePickerModuleTest method nativeMock.
private void nativeMock() {
PowerMockito.mockStatic(Arguments.class);
when(Arguments.createArray()).thenAnswer(new Answer<Object>() {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
return new JavaOnlyArray();
}
});
when(Arguments.createMap()).thenAnswer(new Answer<Object>() {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
return new JavaOnlyMap();
}
});
}
Aggregations