Search in sources :

Example 6 with ElementTemplateNode

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

the class AngularTemplateParserTest method parseTopComment.

@Test
public void parseTopComment() {
    ElementTemplateNode node = (ElementTemplateNode) parse("<!-- comment --><div></div>");
    Assert.assertEquals(0, node.getChildCount());
    Assert.assertEquals("div", node.getTag());
}
Also used : ElementTemplateNode(com.vaadin.flow.template.angular.ElementTemplateNode) Test(org.junit.Test)

Example 7 with ElementTemplateNode

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

the class AngularTemplateParserTest method parseEventHandler.

@Test
public void parseEventHandler() {
    ElementTemplateNode node = (ElementTemplateNode) parse("<button (click)='handle($event)'>");
    Assert.assertEquals(1, node.getEventNames().count());
    Optional<String> event = node.getEventNames().findAny();
    Assert.assertTrue(event.isPresent());
    Assert.assertEquals("click", event.get());
    Optional<String> eventHandler = node.getEventHandlerExpression("click");
    Assert.assertTrue(eventHandler.isPresent());
    Assert.assertEquals("handle($event)", eventHandler.get());
}
Also used : ElementTemplateNode(com.vaadin.flow.template.angular.ElementTemplateNode) Test(org.junit.Test)

Example 8 with ElementTemplateNode

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

the class AngularTemplateParserTest method parseInnerComment.

@Test
public void parseInnerComment() {
    ElementTemplateNode node = (ElementTemplateNode) parse("<div> <!-- comment --> <input> </div>");
    Assert.assertEquals(4, node.getChildCount());
    Assert.assertEquals("div", node.getTag());
    Assert.assertEquals("input", ((ElementTemplateNode) node.getChild(2)).getTag());
}
Also used : ElementTemplateNode(com.vaadin.flow.template.angular.ElementTemplateNode) Test(org.junit.Test)

Example 9 with ElementTemplateNode

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

the class AngularTemplateParserTest method parseWithWhitespacePadding.

@Test
public void parseWithWhitespacePadding() {
    ElementTemplateNode rootNode = (ElementTemplateNode) parse(" \n<input \r> \t ");
    Assert.assertEquals("input", rootNode.getTag());
    Assert.assertEquals(0, rootNode.getPropertyNames().count());
    Assert.assertEquals(0, rootNode.getChildCount());
}
Also used : ElementTemplateNode(com.vaadin.flow.template.angular.ElementTemplateNode) Test(org.junit.Test)

Example 10 with ElementTemplateNode

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

the class AngularTemplateParserTest method parseBasicTemplate.

@Test
public void parseBasicTemplate() {
    ElementTemplateNode rootNode = (ElementTemplateNode) parse("<div id=bar>baz<input></div>");
    Assert.assertEquals("div", rootNode.getTag());
    Assert.assertEquals(0, rootNode.getPropertyNames().count());
    Assert.assertEquals(0, rootNode.getClassNames().count());
    Assert.assertEquals(1, rootNode.getAttributeNames().count());
    Assert.assertEquals("bar", rootNode.getAttributeBinding("id").get().getValue(null));
    Assert.assertEquals(2, rootNode.getChildCount());
    TextTemplateNode textChild = (TextTemplateNode) rootNode.getChild(0);
    Assert.assertEquals("baz", textChild.getTextBinding().getValue(null));
    ElementTemplateNode inputChild = (ElementTemplateNode) rootNode.getChild(1);
    Assert.assertEquals("input", inputChild.getTag());
    Assert.assertEquals(0, inputChild.getAttributeNames().count());
    Assert.assertEquals(0, inputChild.getChildCount());
}
Also used : TextTemplateNode(com.vaadin.flow.template.angular.TextTemplateNode) ElementTemplateNode(com.vaadin.flow.template.angular.ElementTemplateNode) Test(org.junit.Test)

Aggregations

ElementTemplateNode (com.vaadin.flow.template.angular.ElementTemplateNode)19 Test (org.junit.Test)19 TextTemplateNode (com.vaadin.flow.template.angular.TextTemplateNode)8 StateNode (com.vaadin.flow.internal.StateNode)7 BindingValueProvider (com.vaadin.flow.template.angular.BindingValueProvider)6 TemplateNode (com.vaadin.flow.template.angular.TemplateNode)6 Element (com.vaadin.flow.dom.Element)2 TemplateElementStateProvider (com.vaadin.flow.dom.impl.TemplateElementStateProvider)2 ElementTemplateBuilder (com.vaadin.flow.template.angular.ElementTemplateBuilder)1 StaticBindingValueProvider (com.vaadin.flow.template.angular.StaticBindingValueProvider)1 TextTemplateBuilder (com.vaadin.flow.template.angular.TextTemplateBuilder)1