use of com.vaadin.flow.template.angular.TemplateNode in project flow by vaadin.
the class TemplateElementStateProviderTest method setProperty_regularProperty_hasPropertyAndHasProperValue.
@Test
public void setProperty_regularProperty_hasPropertyAndHasProperValue() {
TemplateNode node = TemplateParser.parse("<div></div>", new NullTemplateResolver());
Element element = createElement(node);
element.setProperty("prop", "foo");
Assert.assertTrue(element.hasProperty("prop"));
Assert.assertEquals("foo", element.getProperty("prop"));
List<String> props = element.getPropertyNames().collect(Collectors.toList());
Assert.assertEquals(1, props.size());
Assert.assertEquals("prop", props.get(0));
}
use of com.vaadin.flow.template.angular.TemplateNode in project flow by vaadin.
the class TemplateElementStateProviderTest method setRegularProperty_templateHasBoundProperty_hasPropertyAndHasProperValue.
@Test
public void setRegularProperty_templateHasBoundProperty_hasPropertyAndHasProperValue() {
TemplateNode node = TemplateParser.parse("<div [foo]='bar'></div>", new NullTemplateResolver());
Element element = createElement(node);
element.setProperty("prop", "foo");
Assert.assertTrue(element.hasProperty("prop"));
Assert.assertEquals("foo", element.getProperty("prop"));
Set<String> props = element.getPropertyNames().collect(Collectors.toSet());
Assert.assertEquals(2, props.size());
Assert.assertTrue(props.contains("foo"));
Assert.assertTrue(props.contains("prop"));
}
use of com.vaadin.flow.template.angular.TemplateNode in project flow by vaadin.
the class TemplateElementStateProviderTest method removeRegularProperty_templateHasBoundProperty_hasPropertyAndHasProperValue.
@Test
public void removeRegularProperty_templateHasBoundProperty_hasPropertyAndHasProperValue() {
TemplateNode node = TemplateParser.parse("<div [foo]='bar'></div>", new NullTemplateResolver());
Element element = createElement(node);
element.setProperty("prop", "foo");
element.removeProperty("prop");
Assert.assertFalse(element.hasProperty("prop"));
Set<String> props = element.getPropertyNames().collect(Collectors.toSet());
Assert.assertEquals(1, props.size());
Assert.assertTrue(props.contains("foo"));
}
use of com.vaadin.flow.template.angular.TemplateNode in project flow by vaadin.
the class TemplateElementStateProviderTest method setAttribute_regularAttribute_elementDelegatesAttributeToOverrideNode.
@Test
public void setAttribute_regularAttribute_elementDelegatesAttributeToOverrideNode() {
TemplateNode node = TemplateParser.parse("<div></div>", new NullTemplateResolver());
Element element = createElement(node);
element.setAttribute("attr", "foo");
StateNode overrideNode = element.getNode().getFeature(TemplateOverridesMap.class).get(node, false);
Assert.assertTrue(BasicElementStateProvider.get().hasAttribute(overrideNode, "attr"));
Assert.assertEquals("foo", BasicElementStateProvider.get().getAttribute(overrideNode, "attr"));
List<String> attrs = BasicElementStateProvider.get().getAttributeNames(overrideNode).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 removeAttribute_regularAttribute_hasNoAttribute.
@Test
public void removeAttribute_regularAttribute_hasNoAttribute() {
TemplateNode node = TemplateParser.parse("<div></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());
}
Aggregations