Clean up showNotification test
@@ -7,11 +7,8 @@ import android.os.SystemClock;
import com.facebook.react.bridge.Arguments;
import com.facebook.react.bridge.Callback;
import com.facebook.react.bridge.JavaOnlyMap;
-import com.facebook.react.bridge.ReadableMapKeySetIterator;
-import com.facebook.react.bridge.ReadableType;
import com.facebook.react.bridge.WritableMap;
import com.facebook.react.bridge.WritableNativeArray;
-import com.facebook.react.bridge.WritableNativeMap;
import com.instabug.bug.BugReporting;
import com.instabug.chat.Replies;
import com.instabug.library.Feature;
@@ -44,7 +41,7 @@ import static org.powermock.api.mockito.PowerMockito.mock;
import static org.powermock.api.mockito.PowerMockito.when;
@RunWith(PowerMockRunner.class)
-@PrepareForTest({Looper.class, android.os.Handler.class, BugReporting.class, Replies.class, Surveys.class, SystemClock.class, Runnable.class, WritableNativeMap.class, WritableNativeArray.class, JSONObject.class, Arguments.class, InstabugUtil.class, RNInstabugRepliesModule.class, MainThreadHandler.class})
+@PrepareForTest({Looper.class, android.os.Handler.class, BugReporting.class, Replies.class, Surveys.class, SystemClock.class, Runnable.class, WritableNativeArray.class, JSONObject.class, Arguments.class, InstabugUtil.class, RNInstabugRepliesModule.class, MainThreadHandler.class})
public class RNInstabugRepliesModuleTest {
private RNInstabugRepliesModule rnModule = new RNInstabugRepliesModule(null);
@@ -184,10 +181,8 @@ public class RNInstabugRepliesModuleTest {
PowerMockito.mockStatic(Replies.class);
PowerMockito.mockStatic(SystemClock.class);
PowerMockito.mockStatic(Arguments.class);
- PowerMockito.mock(JSONObject.class);
// when
- final long ts = SystemClock.uptimeMillis();
PowerMockito.when(Arguments.createMap())
.thenAnswer(
new Answer<Object>() {
@@ -196,33 +191,8 @@ public class RNInstabugRepliesModuleTest {
return new JavaOnlyMap();
}
});
- PowerMockito.when(SystemClock.uptimeMillis())
- .thenAnswer(
- new Answer<Object>() {
- @Override
- public Object answer(InvocationOnMock invocation) throws Throwable {
- return ts;
- }
- });
-
- HashMap<String, Object> hm = new HashMap<>();
- hm.put("message", "{\"aps\":{\"alert\":\"You have an unread message from RN-TestAnything team\"},\"IBGHost\":true}");
- WritableMap readableMap = MapUtil.toWritableMap(hm);
Map<String, String> map = new HashMap<>();
- ReadableMapKeySetIterator iterator = readableMap.keySetIterator();
- while (iterator.hasNextKey()) {
- String key = iterator.nextKey();
- ReadableType type = readableMap.getType(key);
-
- switch(type) {
- case String:
- String value = readableMap.getString(key);
- map.put(key, value);
- break;
- }
- }
-
PowerMockito.when(Replies.isInstabugNotification(map))
.thenAnswer(
new Answer<Object>() {
@@ -231,6 +201,8 @@ public class RNInstabugRepliesModuleTest {
return true;
}
});
+
+ WritableMap readableMap = MapUtil.toWritableMap(new HashMap<String, Object>());
rnModule.showNotification(readableMap);
PowerMockito.verifyStatic(VerificationModeFactory.times(1));
