Search in sources :

Example 1 with Option

use of org.kie.workbench.common.screens.library.client.settings.util.KieSelectElement.Option in project kie-wb-common by kiegroup.

the class KieEnumSelectElementTest method testSetup.

@Test
public void testSetup() {
    final Element container = spy(new Element());
    final List<Option> options = Arrays.asList(new Option("FOO", "foo"), new Option("Bar", "bar"));
    doReturn(options).when(kieEnumSelectElement).buildOptions(any());
    kieEnumSelectElement.setup(container, TestEnum.values(), TestEnum.FOO, value -> {
    });
    assertEquals(TestEnum.class, kieEnumSelectElement.componentType);
    verify(kieSelectElement).setup(eq(container), eq(options), eq("FOO"), any());
}
Also used : Element(elemental2.dom.Element) Option(org.kie.workbench.common.screens.library.client.settings.util.KieSelectElement.Option) Test(org.junit.Test)

Example 2 with Option

use of org.kie.workbench.common.screens.library.client.settings.util.KieSelectElement.Option in project kie-wb-common by kiegroup.

the class KieEnumSelectElementTest method testNewOption.

@Test
public void testNewOption() {
    doReturn("A").when(kieEnumSelectElement).getLabel(eq(TestEnum.FOO));
    final Option option = kieEnumSelectElement.newOption(TestEnum.FOO);
    assertEquals("A", option.label);
    assertEquals("FOO", option.value);
}
Also used : Option(org.kie.workbench.common.screens.library.client.settings.util.KieSelectElement.Option) Test(org.junit.Test)

Example 3 with Option

use of org.kie.workbench.common.screens.library.client.settings.util.KieSelectElement.Option in project kie-wb-common by kiegroup.

the class KieSelectElementTest method testSetup.

@Test
public void testSetup() {
    final HTMLElement viewRoot = spy(new HTMLElement());
    viewRoot.innerHTML = "bar";
    doReturn(viewRoot).when(view).getElement();
    final HTMLSelectElement selectElement = spy(new HTMLSelectElement());
    doReturn(selectElement).when(view).getSelect();
    final Element container = spy(new Element() {

        @Override
        public Node appendChild(final Node node) {
            if (node instanceof HTMLElement) {
                this.innerHTML += ((HTMLElement) node).innerHTML;
            }
            return node;
        }
    });
    container.innerHTML = "";
    final List<Option> options = singletonList(new Option("Label", "Value"));
    kieSelectElement.setup(container, options, "Value", value -> {
    });
    verify(view).setValue(eq("Value"));
    verify(view).initSelect();
    verify(optionsListPresenter).setup(eq(selectElement), eq(options), any());
    assertEquals("bar", container.innerHTML);
}
Also used : HTMLElement(elemental2.dom.HTMLElement) Element(elemental2.dom.Element) HTMLElement(elemental2.dom.HTMLElement) HTMLSelectElement(elemental2.dom.HTMLSelectElement) Node(elemental2.dom.Node) Option(org.kie.workbench.common.screens.library.client.settings.util.KieSelectElement.Option) HTMLSelectElement(elemental2.dom.HTMLSelectElement) Test(org.junit.Test)

Example 4 with Option

use of org.kie.workbench.common.screens.library.client.settings.util.KieSelectElement.Option in project kie-wb-common by kiegroup.

the class KieEnumSelectElementTest method testBuildOptions.

@Test
public void testBuildOptions() {
    doReturn(new Option("A", "a")).when(kieEnumSelectElement).newOption(any());
    final List<Option> options = kieEnumSelectElement.buildOptions(TestEnum.values());
    assertEquals(2, options.size());
    assertEquals("A", options.get(0).label);
    assertEquals("a", options.get(0).value);
    assertEquals("A", options.get(1).label);
    assertEquals("a", options.get(1).value);
}
Also used : Option(org.kie.workbench.common.screens.library.client.settings.util.KieSelectElement.Option) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)4 Option (org.kie.workbench.common.screens.library.client.settings.util.KieSelectElement.Option)4 Element (elemental2.dom.Element)2 HTMLElement (elemental2.dom.HTMLElement)1 HTMLSelectElement (elemental2.dom.HTMLSelectElement)1 Node (elemental2.dom.Node)1