File tree Expand file tree Collapse file tree
ReactAndroid/src/test/java/com/facebook/react/modules/network Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -200,6 +200,10 @@ public WritableMap answer(InvocationOnMock invocation) throws Throwable {
200200
201201 @ Test
202202 public void testSuccessfulPostRequest () throws Exception {
203+ RCTDeviceEventEmitter emitter = mock (RCTDeviceEventEmitter .class );
204+ ReactApplicationContext context = mock (ReactApplicationContext .class );
205+ when (context .getJSModule (any (Class .class ))).thenReturn (emitter );
206+
203207 OkHttpClient httpClient = mock (OkHttpClient .class );
204208 when (httpClient .newCall (any (Request .class ))).thenAnswer (new Answer <Object >() {
205209 @ Override
@@ -211,12 +215,13 @@ public Object answer(InvocationOnMock invocation) throws Throwable {
211215 OkHttpClient .Builder clientBuilder = mock (OkHttpClient .Builder .class );
212216 when (clientBuilder .build ()).thenReturn (httpClient );
213217 when (httpClient .newBuilder ()).thenReturn (clientBuilder );
214- NetworkingModule networkingModule =
215- new NetworkingModule (mock (ReactApplicationContext .class ), "" , httpClient );
218+ NetworkingModule networkingModule = new NetworkingModule (context , "" , httpClient );
216219
217220 JavaOnlyMap body = new JavaOnlyMap ();
218221 body .putString ("string" , "This is request body" );
219222
223+ mockEvents ();
224+
220225 networkingModule .sendRequest (
221226 "POST" ,
222227 "http://somedomain/bar" ,
You can’t perform that action at this time.
0 commit comments