use of com.vaadin.flow.template.angular.TemplateNode in project flow by vaadin.
the class TemplateElementStateProviderTest method setRegularAttribute_templateHasDifferentAttribute_hasAttributeAndHasProperValue.
@Test
public void setRegularAttribute_templateHasDifferentAttribute_hasAttributeAndHasProperValue() {
TemplateNode node = TemplateParser.parse("<div foo='bar'></div>", new NullTemplateResolver());
Element element = createElement(node);
element.setAttribute("attr", "foo");
Assert.assertTrue(element.hasAttribute("attr"));
Assert.assertTrue(element.hasAttribute("foo"));
Assert.assertEquals("foo", element.getAttribute("attr"));
Assert.assertEquals("bar", element.getAttribute("foo"));
Set<String> attrs = element.getAttributeNames().collect(Collectors.toSet());
Assert.assertEquals(2, attrs.size());
Assert.assertTrue(attrs.contains("foo"));
Assert.assertTrue(attrs.contains("attr"));
}
use of com.vaadin.flow.template.angular.TemplateNode in project flow by vaadin.
the class TemplateElementStateProviderTest method removeAttribute_regularAttributeAndTemplateHasChildren_hasNoAttributeAndNoException.
@Test
public void removeAttribute_regularAttributeAndTemplateHasChildren_hasNoAttributeAndNoException() {
TemplateNode node = TemplateParser.parse("<div><span></span></div>", new NullTemplateResolver());
Element element = createElement(node);
element.setAttribute("attr", "foo");
element.removeAttribute("attr");
Assert.assertFalse(element.hasAttribute("attr"));
List<String> props = element.getAttributeNames().collect(Collectors.toList());
Assert.assertEquals(0, props.size());
}
use of com.vaadin.flow.template.angular.TemplateNode in project flow by vaadin.
the class TemplateElementStateProviderTest method setRegularAttribute_templateHasAttribute_hasAttributeAndHasProperValue.
@Test
public void setRegularAttribute_templateHasAttribute_hasAttributeAndHasProperValue() {
TemplateNode node = TemplateParser.parse("<div foo='bar'></div>", new NullTemplateResolver());
Element element = createElement(node);
element.setAttribute("foo", "newValue");
Assert.assertTrue(element.hasAttribute("foo"));
Assert.assertEquals("newValue", element.getAttribute("foo"));
Set<String> attrs = element.getAttributeNames().collect(Collectors.toSet());
Assert.assertEquals(1, attrs.size());
Assert.assertTrue(attrs.contains("foo"));
}
use of com.vaadin.flow.template.angular.TemplateNode in project flow by vaadin.
the class TemplateElementStateProviderTest method setAttribute_regularAttributeAndTemplateHasChildren_hasAttributeAndHasProperValueAndNoException.
@Test
public void setAttribute_regularAttributeAndTemplateHasChildren_hasAttributeAndHasProperValueAndNoException() {
TemplateNode node = TemplateParser.parse("<div><span></span></div>", new NullTemplateResolver());
Element element = createElement(node);
element.setAttribute("attr", "foo");
Assert.assertTrue(element.hasAttribute("attr"));
Assert.assertEquals("foo", element.getAttribute("attr"));
List<String> attrs = element.getAttributeNames().collect(Collectors.toList());
Assert.assertEquals(1, attrs.size());
Assert.assertEquals("attr", attrs.get(0));
}
use of com.vaadin.flow.template.angular.TemplateNode in project flow by vaadin.
the class TemplateElementStateProviderTest method setRegularProperty_templateHasAttribute_hasPropertyAndHasProperValue.
@Test
public void setRegularProperty_templateHasAttribute_hasPropertyAndHasProperValue() {
TemplateNode node = TemplateParser.parse("<div foo='bar'></div>", new NullTemplateResolver());
Element element = createElement(node);
element.setProperty("foo", "newValue");
Assert.assertTrue(element.hasProperty("foo"));
Assert.assertEquals("newValue", element.getProperty("foo"));
Set<String> props = element.getPropertyNames().collect(Collectors.toSet());
Assert.assertEquals(1, props.size());
Assert.assertTrue(props.contains("foo"));
}
Aggregations