77import com .facebook .react .bridge .Arguments ;
88import com .facebook .react .bridge .Callback ;
99import com .facebook .react .bridge .JavaOnlyMap ;
10- import com .facebook .react .bridge .ReadableMapKeySetIterator ;
11- import com .facebook .react .bridge .ReadableType ;
1210import com .facebook .react .bridge .WritableMap ;
1311import com .facebook .react .bridge .WritableNativeArray ;
14- import com .facebook .react .bridge .WritableNativeMap ;
1512import com .instabug .bug .BugReporting ;
1613import com .instabug .chat .Replies ;
1714import com .instabug .library .Feature ;
4441import static org .powermock .api .mockito .PowerMockito .when ;
4542
4643@ 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 })
4845
4946public class RNInstabugRepliesModuleTest {
5047 private RNInstabugRepliesModule rnModule = new RNInstabugRepliesModule (null );
@@ -184,10 +181,8 @@ public Boolean answer(InvocationOnMock invocation) throws Throwable {
184181 PowerMockito .mockStatic (Replies .class );
185182 PowerMockito .mockStatic (SystemClock .class );
186183 PowerMockito .mockStatic (Arguments .class );
187- PowerMockito .mock (JSONObject .class );
188184
189185 // when
190- final long ts = SystemClock .uptimeMillis ();
191186 PowerMockito .when (Arguments .createMap ())
192187 .thenAnswer (
193188 new Answer <Object >() {
@@ -196,33 +191,8 @@ public Object answer(InvocationOnMock invocation) throws Throwable {
196191 return new JavaOnlyMap ();
197192 }
198193 });
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 );
211194
212195 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-
226196 PowerMockito .when (Replies .isInstabugNotification (map ))
227197 .thenAnswer (
228198 new Answer <Object >() {
@@ -231,6 +201,8 @@ public Object answer(InvocationOnMock invocation) throws Throwable {
231201 return true ;
232202 }
233203 });
204+
205+ WritableMap readableMap = MapUtil .toWritableMap (new HashMap <String , Object >());
234206 rnModule .showNotification (readableMap );
235207
236208 PowerMockito .verifyStatic (VerificationModeFactory .times (1 ));
0 commit comments