use of elemental2.dom.HTMLOptionElement in project kie-wb-common by kiegroup.
the class TimeSelectorViewTest method testReloadTimeZoneSelectorIsOffsetMode.
@Test
public void testReloadTimeZoneSelectorIsOffsetMode() {
final HTMLOptionElement none = mock(HTMLOptionElement.class);
doReturn(none).when(view).createNoneOption();
doReturn(true).when(view).getIsOffsetMode();
view.reloadTimeZoneSelector();
verify(view).populateTimeZoneSelectorWithOffSets();
verify(view, never()).populateTimeZoneSelectorWithIds();
}
use of elemental2.dom.HTMLOptionElement in project kie-wb-common by kiegroup.
the class DataTypeSelectViewTest method testMakeOptionGroup.
@Test
@SuppressWarnings("unchecked")
public void testMakeOptionGroup() {
final String dataTypeName = "name";
final String groupTitle = "Title";
final DataType dataType = makeDataType(dataTypeName);
final List<DataType> dataTypes = Collections.singletonList(dataType);
final HTMLOptGroupElement expectedGroupElement = mock(HTMLOptGroupElement.class);
final HTMLOptionElement optionElement = mock(HTMLOptionElement.class);
doReturn(expectedGroupElement).when(view).makeHTMLOptGroupElement();
doReturn(optionElement).when(view).makeOption(eq(dataType), any(Function.class));
final HTMLOptGroupElement actualGroupElement = view.makeOptionGroup(groupTitle, dataTypes, DataType::getName);
verify(expectedGroupElement).appendChild(optionElement);
assertEquals(expectedGroupElement, actualGroupElement);
assertEquals(groupTitle, actualGroupElement.label);
}
use of elemental2.dom.HTMLOptionElement in project kie-wb-common by kiegroup.
the class DataTypeSelectViewTest method testOptionGroupSorting.
@Test
@SuppressWarnings("unchecked")
public void testOptionGroupSorting() {
final HTMLOptGroupElement groupElement = mock(HTMLOptGroupElement.class);
final HTMLOptionElement optionElement = mock(HTMLOptionElement.class);
final DataType customDataType1 = makeDataType("b");
final DataType customDataType2 = makeDataType("a");
final List<DataType> customDataTypes = new Lists.Builder().add(customDataType1).add(customDataType2).build();
doReturn(groupElement).when(view).makeHTMLOptGroupElement();
doReturn(optionElement).when(view).makeHTMLOptionElement();
when(translationService.format(DataTypeSelectView_DefaultTitle)).thenReturn("Default");
when(translationService.format(DataTypeSelectView_CustomTitle)).thenReturn("Custom");
when(dataTypeStore.getTopLevelDataTypes()).thenReturn(customDataTypes);
doAnswer(i -> {
final BuiltInType bit = (BuiltInType) i.getArguments()[0];
final DataTypeManager dtm = mock(DataTypeManager.class);
final DataType dt = makeDataType(bit.getName());
when(dtm.get()).thenReturn(dt);
return dtm;
}).when(dataTypeManager).from(any(BuiltInType.class));
doAnswer(i -> dataTypeUtils.defaultDataTypes()).when(presenter).getDefaultDataTypes();
doAnswer(i -> dataTypeUtils.customDataTypes()).when(presenter).getCustomDataTypes();
view.setupDropdownItems();
final int visibleItems = BuiltInType.values().length - 1;
// Check all items were added to the group minus the UNDEFINED item
verify(view, times(visibleItems + customDataTypes.size())).makeOption(dataTypeCaptor.capture(), any(Function.class));
final List<DataType> dataTypes = dataTypeCaptor.getAllValues();
// Check the items were sorted correctly
assertEquals("Any", dataTypes.get(0).getType());
assertEquals("boolean", dataTypes.get(1).getType());
assertEquals("context", dataTypes.get(2).getType());
assertEquals("date", dataTypes.get(3).getType());
assertEquals("date and time", dataTypes.get(4).getType());
assertEquals("days and time duration", dataTypes.get(5).getType());
assertEquals("number", dataTypes.get(6).getType());
assertEquals("string", dataTypes.get(7).getType());
assertEquals("time", dataTypes.get(8).getType());
assertEquals("years and months duration", dataTypes.get(9).getType());
final int customDataTypesOffset = visibleItems;
assertEquals("a", dataTypes.get(customDataTypesOffset).getType());
assertEquals("b", dataTypes.get(customDataTypesOffset + 1).getType());
}
use of elemental2.dom.HTMLOptionElement in project kie-wb-common by kiegroup.
the class KieAssetsDropdownView method selectOption.
protected HTMLOptionElement selectOption() {
final HTMLOptionElement option = makeHTMLOptionElement();
option.text = translationService.format(KieAssetsDropdownView_Select);
option.value = "";
return option;
}
use of elemental2.dom.HTMLOptionElement in project kie-wb-common by kiegroup.
the class KieAssetsDropdownViewTest method selectOption.
@Test
public void selectOption() {
final HTMLOptionElement retrieved = kieAssetsDropdownView.selectOption();
assertNotNull(retrieved);
assertEquals(KIEASSETSDROPDOWNVIEW_SELECT, retrieved.text);
assertEquals("", retrieved.value);
}
Aggregations