Add callback for Connection/Disconnection to Metro

Reviewed By: bnham

Differential Revision: D6447126

fbshipit-source-id: d4c8a4dfb65c2a378f7fe696c8617ff5f3c6cb68
This commit is contained in:
Paco Estevez Garcia
2017-12-07 09:31:18 -08:00
committed by Facebook Github Bot
parent 8547b7e111
commit 3d5dc872a4
4 changed files with 55 additions and 2 deletions

View File

@@ -9,6 +9,8 @@
package com.facebook.react.packagerconnection;
import com.facebook.react.packagerconnection.ReconnectingWebSocket.ConnectionCallback;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -120,4 +122,20 @@ public class JSPackagerClientTest {
verify(handler, never()).onNotification(any());
verify(handler, never()).onRequest(any(), any(Responder.class));
}
@Test
public void test_onDisconnection_ShouldTriggerDisconnectionCallback() throws IOException {
ConnectionCallback connectionHandler = mock(ConnectionCallback.class);
RequestHandler handler = mock(RequestHandler.class);
final JSPackagerClient client =
new JSPackagerClient("test_client", mSettings, new HashMap<String,RequestHandler>(), connectionHandler);
client.close();
verify(connectionHandler, never()).onConnected();
verify(connectionHandler, times(1)).onDisconnected();
verify(handler, never()).onNotification(any());
verify(handler, never()).onRequest(any(), any(Responder.class));
}
}