7
7
import com .facebook .react .bridge .Arguments ;
8
8
import com .facebook .react .bridge .Callback ;
9
9
import com .facebook .react .bridge .JavaOnlyMap ;
10
- import com .facebook .react .bridge .ReadableMapKeySetIterator ;
11
- import com .facebook .react .bridge .ReadableType ;
12
10
import com .facebook .react .bridge .WritableMap ;
13
11
import com .facebook .react .bridge .WritableNativeArray ;
14
- import com .facebook .react .bridge .WritableNativeMap ;
15
12
import com .instabug .bug .BugReporting ;
16
13
import com .instabug .chat .Replies ;
17
14
import com .instabug .library .Feature ;
44
41
import static org .powermock .api .mockito .PowerMockito .when ;
45
42
46
43
@ RunWith (PowerMockRunner .class )
47
- @ 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 })
44
+ @ 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 })
48
45
49
46
public class RNInstabugRepliesModuleTest {
50
47
private RNInstabugRepliesModule rnModule = new RNInstabugRepliesModule (null );
@@ -184,10 +181,8 @@ public Boolean answer(InvocationOnMock invocation) throws Throwable {
184
181
PowerMockito .mockStatic (Replies .class );
185
182
PowerMockito .mockStatic (SystemClock .class );
186
183
PowerMockito .mockStatic (Arguments .class );
187
- PowerMockito .mock (JSONObject .class );
188
184
189
185
// when
190
- final long ts = SystemClock .uptimeMillis ();
191
186
PowerMockito .when (Arguments .createMap ())
192
187
.thenAnswer (
193
188
new Answer <Object >() {
@@ -196,33 +191,8 @@ public Object answer(InvocationOnMock invocation) throws Throwable {
196
191
return new JavaOnlyMap ();
197
192
}
198
193
});
199
- PowerMockito .when (SystemClock .uptimeMillis ())
200
- .thenAnswer (
201
- new Answer <Object >() {
202
- @ Override
203
- public Object answer (InvocationOnMock invocation ) throws Throwable {
204
- return ts ;
205
- }
206
- });
207
-
208
- HashMap <String , Object > hm = new HashMap <>();
209
- hm .put ("message" , "{\" aps\" :{\" alert\" :\" You have an unread message from RN-TestAnything team\" },\" IBGHost\" :true}" );
210
- WritableMap readableMap = MapUtil .toWritableMap (hm );
211
194
212
195
Map <String , String > map = new HashMap <>();
213
- ReadableMapKeySetIterator iterator = readableMap .keySetIterator ();
214
- while (iterator .hasNextKey ()) {
215
- String key = iterator .nextKey ();
216
- ReadableType type = readableMap .getType (key );
217
-
218
- switch (type ) {
219
- case String :
220
- String value = readableMap .getString (key );
221
- map .put (key , value );
222
- break ;
223
- }
224
- }
225
-
226
196
PowerMockito .when (Replies .isInstabugNotification (map ))
227
197
.thenAnswer (
228
198
new Answer <Object >() {
@@ -231,6 +201,8 @@ public Object answer(InvocationOnMock invocation) throws Throwable {
231
201
return true ;
232
202
}
233
203
});
204
+
205
+ WritableMap readableMap = MapUtil .toWritableMap (new HashMap <String , Object >());
234
206
rnModule .showNotification (readableMap );
235
207
236
208
PowerMockito .verifyStatic (VerificationModeFactory .times (1 ));
0 commit comments