use of com.vaadin.flow.template.angular.TemplateNode in project flow by vaadin.
the class ForElementTemplateNodeTest method oneChildWithTextBinding.
@Test
public void oneChildWithTextBinding() {
TemplateNode divTemplateNode = parse("<div><li *ngFor='let item of items' foo='static'>{{item.text}}</li></div>");
TemplateNode forTemplateNode = divTemplateNode.getChild(0);
Element div = getElement(divTemplateNode);
Map<String, String> data = new HashMap<>();
data.put("text", "textValue");
StateNode model = createModel(div, "items", data);
Assert.assertEquals(1, forTemplateNode.getGeneratedElementCount(model));
Assert.assertEquals("textValue", forTemplateNode.getElement(0, model).getText());
}
use of com.vaadin.flow.template.angular.TemplateNode in project flow by vaadin.
the class TemplateElementStateProviderTest method removeAttribute_templateHasBoundAttribute_hasNoAttributeAndHasBoundAttribute.
@Test
public void removeAttribute_templateHasBoundAttribute_hasNoAttributeAndHasBoundAttribute() {
TemplateNode node = TemplateParser.parse("<div [attr.foo]='bar' attr='foo'></div>", new NullTemplateResolver());
Element element = createElement(node);
element.removeAttribute("attr");
Assert.assertFalse(element.hasAttribute("attr"));
Assert.assertTrue(element.hasAttribute("foo"));
List<String> attrs = element.getAttributeNames().collect(Collectors.toList());
Assert.assertEquals(1, attrs.size());
}
use of com.vaadin.flow.template.angular.TemplateNode in project flow by vaadin.
the class TemplateElementStateProviderTest method removeAttribute_templateHasAttribute_hasNoAttribute.
@Test
public void removeAttribute_templateHasAttribute_hasNoAttribute() {
TemplateNode node = TemplateParser.parse("<div foo='bar'></div>", new NullTemplateResolver());
Element element = createElement(node);
element.removeAttribute("foo");
Assert.assertFalse(element.hasAttribute("foo"));
List<String> attrs = element.getAttributeNames().collect(Collectors.toList());
Assert.assertEquals(0, attrs.size());
}
use of com.vaadin.flow.template.angular.TemplateNode in project flow by vaadin.
the class TemplateElementStateProviderTest method getBoundAttribute_setRegularAttribute_hasAttributeAndHasProperValue.
@Test
public void getBoundAttribute_setRegularAttribute_hasAttributeAndHasProperValue() {
TemplateNode node = TemplateParser.parse("<div [attr.attr]='foo'></div>", new NullTemplateResolver());
Element element = createElement(node);
element.setAttribute("foo", "bar");
element.getNode().getFeature(ModelMap.class).setValue("foo", "someValue");
Assert.assertTrue(element.hasAttribute("foo"));
Assert.assertTrue(element.hasAttribute("attr"));
Assert.assertEquals("bar", element.getAttribute("foo"));
Assert.assertEquals("someValue", element.getAttribute("attr"));
List<String> attrs = element.getAttributeNames().collect(Collectors.toList());
Assert.assertEquals(2, attrs.size());
Assert.assertTrue(attrs.contains("attr"));
Assert.assertTrue(attrs.contains("foo"));
}
use of com.vaadin.flow.template.angular.TemplateNode in project flow by vaadin.
the class TemplateElementStateProviderTest method removeProperty_templateHasAttribute_hasNoProperty.
@Test
public void removeProperty_templateHasAttribute_hasNoProperty() {
TemplateNode node = TemplateParser.parse("<div foo='bar'></div>", new NullTemplateResolver());
Element element = createElement(node);
Assert.assertFalse(element.hasProperty("foo"));
element.setProperty("foo", "bar");
element.removeProperty("foo");
Assert.assertFalse(element.hasProperty("foo"));
List<String> props = element.getPropertyNames().collect(Collectors.toList());
Assert.assertEquals(0, props.size());
}
Aggregations