use of com.vaadin.testbench.unit.ElementConditionsTest.TextComponent in project testbench by vaadin.
the class ComponentQueryTest method withTextContaining_getsCorrectComponent.
@Test
void withTextContaining_getsCorrectComponent() {
TextComponent span1 = new TextComponent("this is sample text for first span");
TextComponent span2 = new TextComponent("this is other text second span");
TextComponent span3 = new TextComponent(null);
UI.getCurrent().getElement().appendChild(span1.getElement(), span2.getElement(), span3.getElement());
Assertions.assertIterableEquals(List.of(span1, span2), $(TextComponent.class).withTextContaining("text").allComponents());
Assertions.assertIterableEquals(List.of(span1, span2), $(TextComponent.class).withTextContaining("span").allComponents());
Assertions.assertIterableEquals(List.of(span1, span2), $(TextComponent.class).withTextContaining("this").allComponents());
Assertions.assertIterableEquals(List.of(span1, span2, span3), $(TextComponent.class).withTextContaining("").allComponents());
Assertions.assertTrue($(TextComponent.class).withTextContaining("textual").allComponents().isEmpty());
}
use of com.vaadin.testbench.unit.ElementConditionsTest.TextComponent in project testbench by vaadin.
the class ComponentQueryTest method withText_exactMatch_getsCorrectComponent.
@Test
void withText_exactMatch_getsCorrectComponent() {
TextComponent span1 = new TextComponent("sample text");
TextComponent span2 = new TextComponent("other text");
TextComponent span3 = new TextComponent(null);
UI.getCurrent().getElement().appendChild(span1.getElement(), span2.getElement(), span3.getElement());
Assertions.assertSame(span1, $(TextComponent.class).withText("sample text").findComponent());
Assertions.assertSame(span2, $(TextComponent.class).withText("other text").findComponent());
Assertions.assertTrue($(TextComponent.class).withText("text").allComponents().isEmpty());
Assertions.assertTrue($(TextComponent.class).withText("SAMPLE TEXT").allComponents().isEmpty());
Assertions.assertTrue($(TextComponent.class).withText("other TEXT").allComponents().isEmpty());
}
Aggregations