Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests for PluginMethodHandler #3153

Merged
merged 6 commits into from Jun 30, 2020
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion android/capacitor/build.gradle
Expand Up @@ -71,4 +71,4 @@ 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'}
imhoffd marked this conversation as resolved.
Show resolved Hide resolved
@@ -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);
}
}