Skip to content

Commit dd7077e

Browse files
authored
test(android): add tests for PluginMethodHandler (#3153)
1 parent 84ca1ed commit dd7077e

File tree

2 files changed

+46
-1
lines changed

2 files changed

+46
-1
lines changed

android/capacitor/build.gradle

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,5 @@ dependencies {
7171
androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
7272
implementation "org.apache.cordova:framework:$cordovaAndroidVersion"
7373
testImplementation 'org.json:json:20140107'
74-
}
74+
testImplementation 'org.mockito:mockito-inline:2.13.0'
75+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package com.getcapacitor;
2+
3+
import org.junit.Test;
4+
5+
import java.lang.reflect.Method;
6+
7+
import static org.junit.Assert.assertEquals;
8+
import static org.mockito.BDDMockito.given;
9+
import static org.mockito.Mockito.mock;
10+
11+
public class PluginMethodHandleTest {
12+
@Test
13+
public void getNameReturnsMethodName() {
14+
PluginMethod pluginMethod = mock(PluginMethod.class);
15+
Method mockMethod = mock(Method.class);
16+
17+
given(mockMethod.getName()).willReturn("methodName");
18+
PluginMethodHandle pluginMethodHandle = new PluginMethodHandle(mockMethod, pluginMethod);
19+
20+
assertEquals(pluginMethodHandle.getName(), "methodName");
21+
}
22+
23+
@Test
24+
public void getMethodHandleReturnsMethodHandle() {
25+
PluginMethod pluginMethod = mock(PluginMethod.class);
26+
Method mockMethod = mock(Method.class);
27+
28+
given(pluginMethod.returnType()).willReturn("returnType");
29+
PluginMethodHandle pluginMethodHandle = new PluginMethodHandle(mockMethod, pluginMethod);
30+
31+
assertEquals(pluginMethodHandle.getReturnType(), "returnType");
32+
}
33+
34+
35+
@Test
36+
public void getMethodReturnsMethod() {
37+
PluginMethod pluginMethod = mock(PluginMethod.class);
38+
Method mockMethod = mock(Method.class);
39+
40+
PluginMethodHandle pluginMethodHandle = new PluginMethodHandle(mockMethod, pluginMethod);
41+
42+
assertEquals(pluginMethodHandle.getMethod(), mockMethod);
43+
}
44+
}

0 commit comments

Comments
 (0)