use of com.vaadin.flow.template.angular.ElementTemplateBuilder in project flow by vaadin.
the class TemplateElementStateProviderTest method testEmptyElement.
@Test
public void testEmptyElement() {
ElementTemplateBuilder builder = new ElementTemplateBuilder("div");
Element element = createElement(builder);
Assert.assertEquals("div", element.getTag());
Assert.assertFalse(element.isTextNode());
Assert.assertNull(element.getParent());
Assert.assertEquals(0, element.getChildCount());
Assert.assertEquals(0, element.getPropertyNames().count());
Assert.assertEquals(0, element.getAttributeNames().count());
}
use of com.vaadin.flow.template.angular.ElementTemplateBuilder in project flow by vaadin.
the class TemplateElementStateProviderTest method testTextNodeInParent.
@Test
public void testTextNodeInParent() {
ElementTemplateBuilder builder = new ElementTemplateBuilder("div").addChild(new TextTemplateBuilder(new StaticBindingValueProvider("Hello")));
Element element = createElement(builder);
Assert.assertEquals("div", element.getTag());
Assert.assertEquals("Hello", element.getTextRecursively());
Element child = element.getChild(0);
Assert.assertTrue(child.isTextNode());
Assert.assertEquals(element, child.getParent());
}
use of com.vaadin.flow.template.angular.ElementTemplateBuilder in project flow by vaadin.
the class TemplateElementStateProviderTest method testTemplateInBasicElement.
@Test
public void testTemplateInBasicElement() {
Element templateElement = createElement(new ElementTemplateBuilder("template"));
Element basicElement = new Element("basic");
basicElement.appendChild(templateElement);
Element child = basicElement.getChild(0);
Assert.assertEquals("template", child.getTag());
Assert.assertEquals(templateElement, child);
Element parent = templateElement.getParent();
Assert.assertEquals("basic", parent.getTag());
Assert.assertEquals(basicElement, parent);
}
use of com.vaadin.flow.template.angular.ElementTemplateBuilder in project flow by vaadin.
the class TemplateElementStateProviderTest method testElementStringProperties.
@Test
public void testElementStringProperties() {
ElementTemplateBuilder builder = new ElementTemplateBuilder("div").setProperty("a1", new StaticBindingValueProvider("v1")).setProperty("a2", new StaticBindingValueProvider("v2"));
Element element = createElement(builder);
Assert.assertEquals("v1", element.getProperty("a1"));
Assert.assertEquals("v2", element.getProperty("a2"));
Assert.assertEquals(new HashSet<>(Arrays.asList("a1", "a2")), element.getPropertyNames().collect(Collectors.toSet()));
}
use of com.vaadin.flow.template.angular.ElementTemplateBuilder in project flow by vaadin.
the class TemplateElementStateProviderTest method testElementSubProperty.
@Test
public void testElementSubProperty() {
String modelPath = "bean.name";
ElementTemplateBuilder builder = new ElementTemplateBuilder("div").setProperty("prop", new ModelValueBindingProvider(modelPath));
Element element = createElement(builder);
StateNode stateNode = element.getNode();
ModelMap.get(stateNode).resolveModelMap("bean").setValue("name", "John");
Assert.assertEquals("John", element.getProperty("prop"));
}
Aggregations