|
38 | 38 | import org.mockito.invocation.InvocationOnMock; |
39 | 39 | import org.mockito.stubbing.Answer; |
40 | 40 | import org.powermock.api.mockito.PowerMockito; |
| 41 | +import org.powermock.core.classloader.annotations.PowerMockIgnore; |
41 | 42 | import org.powermock.core.classloader.annotations.PrepareForTest; |
42 | 43 | import org.powermock.modules.junit4.PowerMockRunner; |
43 | 44 | import org.powermock.reflect.Whitebox; |
|
57 | 58 | import static org.powermock.api.mockito.PowerMockito.when; |
58 | 59 |
|
59 | 60 | @RunWith(PowerMockRunner.class) |
60 | | -@PrepareForTest({Looper.class, android.os.Handler.class, Instabug.class, BugReporting.class, CrashReporting.class, FeatureRequests.class, Chats.class, Replies.class, SystemClock.class, Surveys.class, Runnable.class, WritableNativeArray.class, JSONObject.class, RNInstabugReactnativeModule.class, Arguments.class, Log.class, MainThreadHandler.class}) |
| 61 | +@PrepareForTest({Looper.class, android.os.Handler.class, Instabug.class, BugReporting.class, FeatureRequests.class, Chats.class, Replies.class, SystemClock.class, Surveys.class, Runnable.class, WritableNativeArray.class, JSONObject.class, RNInstabugReactnativeModule.class, Arguments.class, Log.class, MainThreadHandler.class}) |
| 62 | + |
61 | 63 |
|
62 | 64 | public class RNInstabugReactnativeModuleTest { |
63 | 65 |
|
@@ -86,57 +88,57 @@ public Boolean answer(InvocationOnMock invocation) throws Throwable { |
86 | 88 |
|
87 | 89 | /********CrashReporting*********/ |
88 | 90 |
|
89 | | - @Test |
90 | | - public void givenFalse$CrashReportingEnabled_whenQuery_thenShouldCallNativeApiWithDisabled() { |
91 | | - // given |
92 | | - PowerMockito.mockStatic(CrashReporting.class); |
93 | | - // when |
94 | | - rnModule.setCrashReportingEnabled(false); |
95 | | - // then |
96 | | - PowerMockito.verifyStatic(VerificationModeFactory.times(1)); |
97 | | - CrashReporting.setState(Feature.State.DISABLED); |
98 | | - } |
99 | | - |
100 | | - @Test |
101 | | - public void givenTrue$CrashReportingEnabled_whenQuery_thenShouldCallNativeApiWithEnabled() { |
102 | | - // given |
103 | | - PowerMockito.mockStatic(CrashReporting.class); |
104 | | - // when |
105 | | - rnModule.setCrashReportingEnabled(true); |
106 | | - // then |
107 | | - PowerMockito.verifyStatic(VerificationModeFactory.times(1)); |
108 | | - CrashReporting.setState(Feature.State.ENABLED); |
109 | | - } |
110 | | - |
111 | | - @Test |
112 | | - public void givenString$sendHandledJSCrash_whenQuery_thenShouldCallNativeApiWithArgs() throws Exception { |
113 | | - |
114 | | - JSONObject json = mock(JSONObject.class); |
115 | | - PowerMockito.whenNew(JSONObject.class).withArguments("exception").thenReturn(json); |
116 | | - |
117 | | - // given |
118 | | - PowerMockito.mockStatic(CrashReporting.class); |
119 | | - // when |
120 | | - rnModule.sendHandledJSCrash("exception"); |
121 | | - // then |
122 | | - JSONObject jsonObject = new JSONObject("exception"); |
123 | | - PowerMockito.verifyPrivate(CrashReporting.class, VerificationModeFactory.times(1)).invoke("reportException", jsonObject, true); |
124 | | - } |
125 | | - |
126 | | - @Test |
127 | | - public void givenString$sendJSCrash_whenQuery_thenShouldCallNativeApiWithArgs() throws Exception { |
128 | | - |
129 | | - JSONObject json = mock(JSONObject.class); |
130 | | - PowerMockito.whenNew(JSONObject.class).withArguments("exception").thenReturn(json); |
131 | | - |
132 | | - // given |
133 | | - PowerMockito.mockStatic(CrashReporting.class); |
134 | | - // when |
135 | | - rnModule.sendJSCrash("exception"); |
136 | | - // then |
137 | | - JSONObject jsonObject = new JSONObject("exception"); |
138 | | - PowerMockito.verifyPrivate(CrashReporting.class, VerificationModeFactory.times(1)).invoke("reportException", jsonObject, false); |
139 | | - } |
| 91 | +// @Test |
| 92 | +// public void givenFalse$CrashReportingEnabled_whenQuery_thenShouldCallNativeApiWithDisabled() { |
| 93 | +// // given |
| 94 | +// PowerMockito.mockStatic(CrashReporting.class); |
| 95 | +// // when |
| 96 | +// rnModule.setCrashReportingEnabled(false); |
| 97 | +// // then |
| 98 | +// PowerMockito.verifyStatic(VerificationModeFactory.times(1)); |
| 99 | +// CrashReporting.setState(Feature.State.DISABLED); |
| 100 | +// } |
| 101 | +// |
| 102 | +// @Test |
| 103 | +// public void givenTrue$CrashReportingEnabled_whenQuery_thenShouldCallNativeApiWithEnabled() { |
| 104 | +// // given |
| 105 | +// PowerMockito.mockStatic(CrashReporting.class); |
| 106 | +// // when |
| 107 | +// rnModule.setCrashReportingEnabled(true); |
| 108 | +// // then |
| 109 | +// PowerMockito.verifyStatic(VerificationModeFactory.times(1)); |
| 110 | +// CrashReporting.setState(Feature.State.ENABLED); |
| 111 | +// } |
| 112 | +// |
| 113 | +// @Test |
| 114 | +// public void givenString$sendHandledJSCrash_whenQuery_thenShouldCallNativeApiWithArgs() throws Exception { |
| 115 | +// |
| 116 | +// JSONObject json = mock(JSONObject.class); |
| 117 | +// PowerMockito.whenNew(JSONObject.class).withArguments("exception").thenReturn(json); |
| 118 | +// |
| 119 | +// // given |
| 120 | +// PowerMockito.mockStatic(CrashReporting.class); |
| 121 | +// // when |
| 122 | +// rnModule.sendHandledJSCrash("exception"); |
| 123 | +// // then |
| 124 | +// JSONObject jsonObject = new JSONObject("exception"); |
| 125 | +// PowerMockito.verifyPrivate(CrashReporting.class, VerificationModeFactory.times(1)).invoke("reportException", jsonObject, true); |
| 126 | +// } |
| 127 | +// |
| 128 | +// @Test |
| 129 | +// public void givenString$sendJSCrash_whenQuery_thenShouldCallNativeApiWithArgs() throws Exception { |
| 130 | +// |
| 131 | +// JSONObject json = mock(JSONObject.class); |
| 132 | +// PowerMockito.whenNew(JSONObject.class).withArguments("exception").thenReturn(json); |
| 133 | +// |
| 134 | +// // given |
| 135 | +// PowerMockito.mockStatic(CrashReporting.class); |
| 136 | +// // when |
| 137 | +// rnModule.sendJSCrash("exception"); |
| 138 | +// // then |
| 139 | +// JSONObject jsonObject = new JSONObject("exception"); |
| 140 | +// PowerMockito.verifyPrivate(CrashReporting.class, VerificationModeFactory.times(1)).invoke("reportException", jsonObject, false); |
| 141 | +// } |
140 | 142 |
|
141 | 143 | /********Instabug*********/ |
142 | 144 |
|
|
0 commit comments