mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-06 22:38:37 +08:00
Added progress updates for all XMLHttpRequest upload types / fix crash on closed connection
Reviewed By: mdvacca Differential Revision: D6937754 fbshipit-source-id: 89b963e16adf1bd3200806fd7374d28aa618b62f
This commit is contained in:
committed by
Facebook Github Bot
parent
fdef3784f0
commit
27b6348f86
@@ -200,6 +200,10 @@ public class NetworkingModuleTest {
|
||||
|
||||
@Test
|
||||
public void testSuccessfulPostRequest() throws Exception {
|
||||
RCTDeviceEventEmitter emitter = mock(RCTDeviceEventEmitter.class);
|
||||
ReactApplicationContext context = mock(ReactApplicationContext.class);
|
||||
when(context.getJSModule(any(Class.class))).thenReturn(emitter);
|
||||
|
||||
OkHttpClient httpClient = mock(OkHttpClient.class);
|
||||
when(httpClient.newCall(any(Request.class))).thenAnswer(new Answer<Object>() {
|
||||
@Override
|
||||
@@ -211,12 +215,13 @@ public class NetworkingModuleTest {
|
||||
OkHttpClient.Builder clientBuilder = mock(OkHttpClient.Builder.class);
|
||||
when(clientBuilder.build()).thenReturn(httpClient);
|
||||
when(httpClient.newBuilder()).thenReturn(clientBuilder);
|
||||
NetworkingModule networkingModule =
|
||||
new NetworkingModule(mock(ReactApplicationContext.class), "", httpClient);
|
||||
NetworkingModule networkingModule = new NetworkingModule(context, "", httpClient);
|
||||
|
||||
JavaOnlyMap body = new JavaOnlyMap();
|
||||
body.putString("string", "This is request body");
|
||||
|
||||
mockEvents();
|
||||
|
||||
networkingModule.sendRequest(
|
||||
"POST",
|
||||
"http://somedomain/bar",
|
||||
@@ -630,4 +635,4 @@ public class NetworkingModuleTest {
|
||||
assertThat(requestIdArguments.getAllValues().contains(idx + 1)).isTrue();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user