Search in sources :

Example 6 with TextTemplateNode

use of com.vaadin.flow.template.angular.TextTemplateNode in project flow by vaadin.

the class DefaultTextModelBuiderFactoryTest method verifyStaticText.

private void verifyStaticText(List<TemplateNode> nodes, int index, String expected) {
    Assert.assertEquals(TextTemplateNode.class, nodes.get(index).getClass());
    TextTemplateNode textNode = (TextTemplateNode) nodes.get(index);
    Assert.assertEquals(expected, textNode.getTextBinding().getValue(null));
}
Also used : TextTemplateNode(com.vaadin.flow.template.angular.TextTemplateNode)

Example 7 with TextTemplateNode

use of com.vaadin.flow.template.angular.TextTemplateNode in project flow by vaadin.

the class AngularTemplateParserTest method parseParameterizedTextTemplate.

@Test
public void parseParameterizedTextTemplate() {
    ElementTemplateNode rootNode = (ElementTemplateNode) parse("<div id='foo'>{{bar}}<input></div>");
    Assert.assertEquals("div", rootNode.getTag());
    Assert.assertEquals(1, rootNode.getAttributeNames().count());
    Assert.assertEquals("foo", rootNode.getAttributeBinding("id").get().getValue(null));
    Assert.assertEquals(2, rootNode.getChildCount());
    TextTemplateNode textChild = (TextTemplateNode) rootNode.getChild(0);
    BindingValueProvider binding = textChild.getTextBinding();
    StateNode node = new StateNode(ModelMap.class);
    // Explicitly set "bar" property to null. So model has property "bar".
    // See #970
    ModelMap.get(node).setValue("bar", null);
    Assert.assertNull(binding.getValue(node));
    String value = "someValue";
    ModelMap.get(node).setValue("bar", value);
    Assert.assertEquals(value, binding.getValue(node));
}
Also used : TextTemplateNode(com.vaadin.flow.template.angular.TextTemplateNode) BindingValueProvider(com.vaadin.flow.template.angular.BindingValueProvider) ElementTemplateNode(com.vaadin.flow.template.angular.ElementTemplateNode) StateNode(com.vaadin.flow.internal.StateNode) Test(org.junit.Test)

Aggregations

TextTemplateNode (com.vaadin.flow.template.angular.TextTemplateNode)7 ElementTemplateNode (com.vaadin.flow.template.angular.ElementTemplateNode)6 Test (org.junit.Test)6 TemplateNode (com.vaadin.flow.template.angular.TemplateNode)4 StateNode (com.vaadin.flow.internal.StateNode)3 BindingValueProvider (com.vaadin.flow.template.angular.BindingValueProvider)1 ElementTemplateBuilder (com.vaadin.flow.template.angular.ElementTemplateBuilder)1 StaticBindingValueProvider (com.vaadin.flow.template.angular.StaticBindingValueProvider)1 TextTemplateBuilder (com.vaadin.flow.template.angular.TextTemplateBuilder)1