use of com.vaadin.testbench.unit.ComponentWrapTest.Span in project testbench by vaadin.
the class ComponentQueryTest method withoutTheme_getsCorrectComponent.
@Test
void withoutTheme_getsCorrectComponent() {
Span target = new Span();
target.getElement().getThemeList().add("my-theme");
final Span first = new Span();
first.getElement().getThemeList().add("custom-theme");
final Span last = new Span();
last.getElement().getThemeList().add("custom-theme");
UI.getCurrent().getElement().appendChild(first.getElement(), target.getElement(), last.getElement());
Assertions.assertEquals(target, $(Span.class).withoutTheme("custom-theme").findComponent());
}
use of com.vaadin.testbench.unit.ComponentWrapTest.Span in project testbench by vaadin.
the class ComponentQueryTest method withAttribute_multipleAttributes_getsCorrectComponents.
@Test
void withAttribute_multipleAttributes_getsCorrectComponents() {
Span target = new Span();
target.getElement().setAttribute("role", "tooltip");
target.getElement().setAttribute("aria-label", "some text");
Span other = new Span();
other.getElement().setAttribute("role", "something");
other.getElement().setAttribute("aria-label", "some other text");
UI.getCurrent().getElement().appendChild(new Span().getElement(), target.getElement(), new Span().getElement(), other.getElement());
Assertions.assertSame(target, $(Span.class).withAttribute("aria-label").withAttribute("role", "tooltip").findComponent());
}
use of com.vaadin.testbench.unit.ComponentWrapTest.Span in project testbench by vaadin.
the class ComponentQueryTest method withoutAttribute_value_getsCorrectComponents.
@Test
void withoutAttribute_value_getsCorrectComponents() {
Span target = new Span();
target.getElement().setAttribute("my-attr", "value");
Span other = new Span();
other.getElement().setAttribute("my-attr", "something else");
Span noAttributes = new Span();
UI.getCurrent().getElement().appendChild(target.getElement(), noAttributes.getElement(), other.getElement());
Assertions.assertIterableEquals(List.of(noAttributes, other), $(Span.class).withoutAttribute("my-attr", "value").allComponents());
Assertions.assertIterableEquals(List.of(target, noAttributes), $(Span.class).withoutAttribute("my-attr", "something else").allComponents());
Assertions.assertIterableEquals(List.of(target, noAttributes, other), $(Span.class).withoutAttribute("my-attr", "nope").allComponents());
}
use of com.vaadin.testbench.unit.ComponentWrapTest.Span in project testbench by vaadin.
the class ComponentQueryTest method withoutAttribute_absent_getsCorrectComponents.
@Test
void withoutAttribute_absent_getsCorrectComponents() {
Span target = new Span();
target.getElement().setAttribute("my-attr", "value");
Span other = new Span();
other.getElement().setAttribute("other-attr", "value");
Span noAttributes = new Span();
UI.getCurrent().getElement().appendChild(target.getElement(), noAttributes.getElement(), other.getElement());
Assertions.assertIterableEquals(List.of(noAttributes, other), $(Span.class).withoutAttribute("my-attr").allComponents());
Assertions.assertIterableEquals(List.of(target, noAttributes), $(Span.class).withoutAttribute("other-attr").allComponents());
Assertions.assertIterableEquals(List.of(target, noAttributes, other), $(Span.class).withoutAttribute("role").allComponents());
}
use of com.vaadin.testbench.unit.ComponentWrapTest.Span in project testbench by vaadin.
the class ComponentQueryTest method withAttribute_value_getsCorrectComponents.
@Test
void withAttribute_value_getsCorrectComponents() {
Span target = new Span();
target.getElement().setAttribute("my-attr", "value");
Span other = new Span();
other.getElement().setAttribute("my-attr", "something else");
UI.getCurrent().getElement().appendChild(new Span().getElement(), target.getElement(), new Span().getElement(), other.getElement());
Assertions.assertSame(target, $(Span.class).withAttribute("my-attr", "value").findComponent());
Assertions.assertSame(other, $(Span.class).withAttribute("my-attr", "something else").findComponent());
Assertions.assertTrue($(Span.class).withAttribute("my-attr", "nope").allComponents().isEmpty());
}