-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(android): add tests for PluginMethodHandler (#3153)
- Loading branch information
1 parent
84ca1ed
commit dd7077e
Showing
2 changed files
with
46 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
android/capacitor/src/test/java/com/getcapacitor/PluginMethodHandleTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package com.getcapacitor; | ||
|
||
import org.junit.Test; | ||
|
||
import java.lang.reflect.Method; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.mockito.BDDMockito.given; | ||
import static org.mockito.Mockito.mock; | ||
|
||
public class PluginMethodHandleTest { | ||
@Test | ||
public void getNameReturnsMethodName() { | ||
PluginMethod pluginMethod = mock(PluginMethod.class); | ||
Method mockMethod = mock(Method.class); | ||
|
||
given(mockMethod.getName()).willReturn("methodName"); | ||
PluginMethodHandle pluginMethodHandle = new PluginMethodHandle(mockMethod, pluginMethod); | ||
|
||
assertEquals(pluginMethodHandle.getName(), "methodName"); | ||
} | ||
|
||
@Test | ||
public void getMethodHandleReturnsMethodHandle() { | ||
PluginMethod pluginMethod = mock(PluginMethod.class); | ||
Method mockMethod = mock(Method.class); | ||
|
||
given(pluginMethod.returnType()).willReturn("returnType"); | ||
PluginMethodHandle pluginMethodHandle = new PluginMethodHandle(mockMethod, pluginMethod); | ||
|
||
assertEquals(pluginMethodHandle.getReturnType(), "returnType"); | ||
} | ||
|
||
|
||
@Test | ||
public void getMethodReturnsMethod() { | ||
PluginMethod pluginMethod = mock(PluginMethod.class); | ||
Method mockMethod = mock(Method.class); | ||
|
||
PluginMethodHandle pluginMethodHandle = new PluginMethodHandle(mockMethod, pluginMethod); | ||
|
||
assertEquals(pluginMethodHandle.getMethod(), mockMethod); | ||
} | ||
} |