Skip to content
New issue

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

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

Already on GitHub? # 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 all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
}
}