mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-02 22:41:18 +08:00
Add callback for Connection/Disconnection to Metro
Reviewed By: bnham Differential Revision: D6447126 fbshipit-source-id: d4c8a4dfb65c2a378f7fe696c8617ff5f3c6cb68
This commit is contained in:
committed by
Facebook Github Bot
parent
8547b7e111
commit
3d5dc872a4
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user