use of com.vaadin.flow.template.angular.JsExpressionBindingProvider in project flow by vaadin.
the class JsExpressionBindingProviderTest method setTemplateProperty_useJsExpression.
@Test
public void setTemplateProperty_useJsExpression() {
JsExpressionBindingProvider binding = new JsExpressionBindingProvider("bar +'foo'");
StateNode node = new StateNode(ModelMap.class, TemplateMap.class);
node.getFeature(TemplateMap.class).setModelDescriptor(new TestModelDescriptor(Collections.singletonMap("bar", BasicModelType.get(String.class).get())));
ModelMap.get(node).setValue("bar", "modelValue");
Assert.assertEquals("modelValuefoo", binding.getValue(node));
}
use of com.vaadin.flow.template.angular.JsExpressionBindingProvider in project flow by vaadin.
the class JsExpressionBindingProviderTest method jsExpressionWithSubProperty.
@Test
public void jsExpressionWithSubProperty() {
JsExpressionBindingProvider binding = new JsExpressionBindingProvider("bean.property");
StateNode beanNode = new StateNode(ModelMap.class);
ModelMap beanModel = ModelMap.get(beanNode);
beanModel.setValue("property", "foo");
StateNode rootNode = new StateNode(TemplateMap.class, ModelMap.class);
Map<String, ModelType> beanProperties = Collections.singletonMap("property", BasicModelType.get(String.class).get());
Map<String, ModelType> modelProperties = Collections.singletonMap("bean", new BeanModelType<>(Object.class, beanProperties));
rootNode.getFeature(TemplateMap.class).setModelDescriptor(new TestModelDescriptor(modelProperties));
ModelMap.get(rootNode).setValue("bean", beanNode);
Assert.assertEquals("foo", binding.getValue(rootNode));
}
Aggregations