Migrate all NativeModules to invalidate()

Summary:
This diff migrates all NativeModules away from onCatalystInstanceDestroy() to the invalidate() method.

Changelog: [Internal]

Reviewed By: JoshuaGross

Differential Revision: D26871595

fbshipit-source-id: 132f6b75e485361835769a2b53bc742eefa47b59
This commit is contained in:
Ramanpreet Nara
2021-03-06 20:30:17 -08:00
committed by Facebook GitHub Bot
parent 18c8417290
commit 3f0df9788b
12 changed files with 20 additions and 23 deletions
@@ -545,7 +545,7 @@ public class NetworkingModuleTest {
}
@Test
public void testCancelAllCallsOnCatalystInstanceDestroy() throws Exception {
public void testCancelAllCallsInvalidate() throws Exception {
PowerMockito.mockStatic(OkHttpCallUtil.class);
final int requests = 3;
final Call[] calls = new Call[requests];
@@ -578,7 +578,7 @@ public class NetworkingModuleTest {
}
verify(mHttpClient, times(3)).newCall(any(Request.class));
mNetworkingModule.onCatalystInstanceDestroy();
mNetworkingModule.invalidate();
PowerMockito.verifyStatic(OkHttpCallUtil.class, times(3));
ArgumentCaptor<OkHttpClient> clientArguments = ArgumentCaptor.forClass(OkHttpClient.class);
ArgumentCaptor<Integer> requestIdArguments = ArgumentCaptor.forClass(Integer.class);
@@ -591,7 +591,7 @@ public class NetworkingModuleTest {
}
@Test
public void testCancelSomeCallsOnCatalystInstanceDestroy() throws Exception {
public void testCancelSomeCallsInvalidate() throws Exception {
PowerMockito.mockStatic(OkHttpCallUtil.class);
final int requests = 3;
final Call[] calls = new Call[requests];
@@ -634,7 +634,7 @@ public class NetworkingModuleTest {
// verifyStatic actually does not clear all calls so far, so we have to check for all of them.
// If `cancelTag` would've been called again for the aborted call, we would have had
// `requests + 1` calls.
mNetworkingModule.onCatalystInstanceDestroy();
mNetworkingModule.invalidate();
PowerMockito.verifyStatic(OkHttpCallUtil.class, times(requests));
clientArguments = ArgumentCaptor.forClass(OkHttpClient.class);
requestIdArguments = ArgumentCaptor.forClass(Integer.class);