Skip to content

Commit

Permalink
test(android): add tests for PluginMethodHandler (#3153)
Browse files Browse the repository at this point in the history
  • Loading branch information
imjacobclark authored Jun 30, 2020
1 parent 84ca1ed commit dd7077e
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 1 deletion.
3 changes: 2 additions & 1 deletion android/capacitor/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,5 @@ dependencies {
androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
implementation "org.apache.cordova:framework:$cordovaAndroidVersion"
testImplementation 'org.json:json:20140107'
}
testImplementation 'org.mockito:mockito-inline:2.13.0'
}
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);
}
}

0 comments on commit dd7077e

Please sign in to comment.