Search in sources :

Example 1 with Span

use of com.vaadin.testbench.unit.ComponentWrapTest.Span in project testbench by vaadin.

the class ComponentQueryTest method withThemeMultipleThemes_getsCorrectComponent.

@Test
void withThemeMultipleThemes_getsCorrectComponent() {
    Span target = new Span();
    target.getElement().getThemeList().add("my-theme");
    target.getElement().getThemeList().add("custom-theme");
    final Span first = new Span();
    first.getElement().getThemeList().add("my-theme");
    final Span last = new Span();
    last.getElement().getThemeList().add("my-theme");
    UI.getCurrent().getElement().appendChild(first.getElement(), target.getElement(), last.getElement());
    Assertions.assertEquals(target, $(Span.class).withTheme("my-theme").withTheme("custom-theme").findComponent());
}
Also used : Span(com.vaadin.testbench.unit.ComponentWrapTest.Span) Test(org.junit.jupiter.api.Test)

Example 2 with Span

use of com.vaadin.testbench.unit.ComponentWrapTest.Span in project testbench by vaadin.

the class ComponentQueryTest method withTheme_getsCorrectComponent.

@Test
void withTheme_getsCorrectComponent() {
    Span target = new Span();
    target.getElement().getThemeList().add("my-theme");
    UI.getCurrent().getElement().appendChild(new Span().getElement(), target.getElement(), new Span().getElement());
    Assertions.assertEquals(target, $(Span.class).withTheme("my-theme").findComponent());
}
Also used : Span(com.vaadin.testbench.unit.ComponentWrapTest.Span) Test(org.junit.jupiter.api.Test)

Example 3 with Span

use of com.vaadin.testbench.unit.ComponentWrapTest.Span in project testbench by vaadin.

the class ComponentQueryTest method withoutAttribute_multipleAttributes_getsCorrectComponents.

@Test
void withoutAttribute_multipleAttributes_getsCorrectComponents() {
    Span span1 = new Span();
    span1.getElement().setAttribute("role", "tooltip");
    Span span2 = new Span();
    span2.getElement().setAttribute("role", "something");
    span2.getElement().setAttribute("aria-label", "some other text");
    Span target = new Span();
    target.getElement().setAttribute("role", "something");
    UI.getCurrent().getElement().appendChild(span1.getElement(), target.getElement(), span2.getElement());
    Assertions.assertSame(target, $(Span.class).withoutAttribute("aria-label").withoutAttribute("role", "tooltip").findComponent());
}
Also used : Span(com.vaadin.testbench.unit.ComponentWrapTest.Span) Test(org.junit.jupiter.api.Test)

Example 4 with Span

use of com.vaadin.testbench.unit.ComponentWrapTest.Span in project testbench by vaadin.

the class ComponentQueryTest method withAttribute_present_getsCorrectComponents.

@Test
void withAttribute_present_getsCorrectComponents() {
    Span target = new Span();
    target.getElement().setAttribute("my-attr", "value");
    Span other = new Span();
    other.getElement().setAttribute("other-attr", "value");
    UI.getCurrent().getElement().appendChild(new Span().getElement(), target.getElement(), new Span().getElement(), other.getElement());
    Assertions.assertSame(target, $(Span.class).withAttribute("my-attr").findComponent());
    Assertions.assertSame(other, $(Span.class).withAttribute("other-attr").findComponent());
    Assertions.assertTrue($(Span.class).withAttribute("nope").allComponents().isEmpty());
}
Also used : Span(com.vaadin.testbench.unit.ComponentWrapTest.Span) Test(org.junit.jupiter.api.Test)

Example 5 with Span

use of com.vaadin.testbench.unit.ComponentWrapTest.Span in project testbench by vaadin.

the class ComponentQueryTest method withoutThemeMultipleThemes_getsCorrectComponent.

@Test
void withoutThemeMultipleThemes_getsCorrectComponent() {
    Span target = new Span();
    target.getElement().getThemeList().add("selection-theme");
    final Span first = new Span();
    first.getElement().getThemeList().add("selection-theme");
    first.getElement().getThemeList().add("my-theme");
    final Span last = new Span();
    last.getElement().getThemeList().add("selection-theme");
    last.getElement().getThemeList().add("custom-theme");
    UI.getCurrent().getElement().appendChild(first.getElement(), target.getElement(), last.getElement());
    Assertions.assertEquals(target, $(Span.class).withoutTheme("my-theme").withoutTheme("custom-theme").findComponent());
}
Also used : Span(com.vaadin.testbench.unit.ComponentWrapTest.Span) Test(org.junit.jupiter.api.Test)

Aggregations

Span (com.vaadin.testbench.unit.ComponentWrapTest.Span)10 Test (org.junit.jupiter.api.Test)10