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());
}
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);
}
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);
}
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);
}
Aggregations