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());
}
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());
}
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());
}
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());
}
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());
}
Aggregations