use of com.vaadin.flow.template.angular.TemplateNode in project flow by vaadin.
the class ScriptParsingTest method scriptWithAttributes.
@Test
public void scriptWithAttributes() {
TemplateNode templateNode = parse("<script type='text/javascript' src='file://foobar'/>");
Assert.assertEquals(ElementTemplateNode.class, templateNode.getClass());
ElementTemplateNode elementTemplate = (ElementTemplateNode) templateNode;
Assert.assertEquals("script", elementTemplate.getTag());
Assert.assertEquals("text/javascript", elementTemplate.getAttributeBinding("type").get().getValue(new StateNode()));
Assert.assertEquals("file://foobar", elementTemplate.getAttributeBinding("src").get().getValue(new StateNode()));
}
use of com.vaadin.flow.template.angular.TemplateNode in project flow by vaadin.
the class ScriptParsingTest method emptyInlineStyle.
@Test
public void emptyInlineStyle() {
TemplateNode templateNode = parse("<style></style>");
Assert.assertEquals(ElementTemplateNode.class, templateNode.getClass());
ElementTemplateNode elementTemplate = (ElementTemplateNode) templateNode;
Assert.assertEquals("style", elementTemplate.getTag());
Assert.assertEquals(0, elementTemplate.getChildCount());
}
use of com.vaadin.flow.template.angular.TemplateNode in project flow by vaadin.
the class AngularTemplateNodeTest method unknownElementLookup.
@Test
public void unknownElementLookup() {
TemplateNode templateNode = parse("<div><div>");
Assert.assertEquals(Optional.empty(), templateNode.findElement(TemplateElementStateProvider.createRootNode(), "foo"));
}
use of com.vaadin.flow.template.angular.TemplateNode in project flow by vaadin.
the class AngularTemplateParserTest method tempalteNodesReused.
@Test
public void tempalteNodesReused() {
String templateString = "<div></div>";
TemplateNode a = TemplateParser.parse(templateString, null);
TemplateNode b = TemplateParser.parse(new ByteArrayInputStream(templateString.getBytes(StandardCharsets.UTF_8)), null);
Assert.assertSame(a, b);
}
use of com.vaadin.flow.template.angular.TemplateNode in project flow by vaadin.
the class ForElementTemplateNodeTest method oneChildWithPropertyBinding.
@Test
public void oneChildWithPropertyBinding() {
TemplateNode divTemplateNode = parse("<div><li *ngFor='let item of items' [value]='item.value'></div>");
TemplateNode templateNode = divTemplateNode.getChild(0);
Element div = getElement(divTemplateNode);
Map<String, String> data = new HashMap<>();
data.put("value", "propertyValue");
StateNode model = createModel(div, "items", data);
Assert.assertEquals(1, templateNode.getGeneratedElementCount(model));
Assert.assertEquals("propertyValue", templateNode.getElement(0, model).getProperty("value"));
}
Aggregations