@Test public void newValue_function() { final JSObject obj = Mockito.mock(JSObject.class); Mockito.when(obj.isFunction()).thenReturn(true); final ScriptValue value = this.factory.newValue(obj); assertNotNull(value); assertEquals(false, value.isArray()); assertEquals(true, value.isFunction()); assertEquals(false, value.isObject()); assertEquals(false, value.isValue()); assertNonValue(value); assertNonArray(value); assertNonObject(value); Mockito.when(this.invoker.invoke(Mockito.same(obj), Mockito.any())).thenReturn("a+b"); final ScriptValue result = value.call("a", "b"); assertNotNull(result); assertEquals(true, result.isValue()); assertEquals("a+b", result.getValue()); }
private void assertNonFunction(final ScriptValue value) { assertNull(value.call("a", "b")); }