Search in sources :

Example 6 with HTMLOptionElement

use of elemental2.dom.HTMLOptionElement in project kie-wb-common by kiegroup.

the class TimeSelectorViewTest method testCreateOptionWithOffset.

@Test
public void testCreateOptionWithOffset() {
    final String offset = "offset";
    final HTMLOptionElement option = new HTMLOptionElement();
    doReturn(option).when(view).getNewOption();
    view.createOptionWithOffset(offset);
    assertEquals(offset, option.value);
    assertEquals(offset, option.text);
}
Also used : HTMLOptionElement(elemental2.dom.HTMLOptionElement) Test(org.junit.Test)

Example 7 with HTMLOptionElement

use of elemental2.dom.HTMLOptionElement in project kie-wb-common by kiegroup.

the class TimeSelectorViewTest method testPopulateTimeZoneSelectorWithIds.

@Test
public void testPopulateTimeZoneSelectorWithIds() {
    final HTMLOptionElement noneOption = mock(HTMLOptionElement.class);
    final HTMLOptionElement tz1Option = mock(HTMLOptionElement.class);
    final HTMLOptionElement tz2Option = mock(HTMLOptionElement.class);
    final List<DMNSimpleTimeZone> timeZones = mock(List.class);
    final DMNSimpleTimeZone tz1 = mock(DMNSimpleTimeZone.class);
    final DMNSimpleTimeZone tz2 = mock(DMNSimpleTimeZone.class);
    when(tz1.getId()).thenReturn("time zone 1");
    when(tz2.getId()).thenReturn("other time zone");
    when(timeZones.size()).thenReturn(2);
    when(timeZones.get(0)).thenReturn(tz1);
    when(timeZones.get(1)).thenReturn(tz2);
    doReturn(tz1Option).when(view).createOptionWithId(tz1);
    doReturn(tz2Option).when(view).createOptionWithId(tz2);
    doReturn(timeZones).when(view).getTimeZones();
    doReturn(noneOption).when(view).createNoneOption();
    doNothing().when(view).timeZoneSelectorRefresh();
    view.populateTimeZoneSelectorWithIds();
    verify(timeZoneSelector).appendChild(noneOption);
    verify(timeZoneSelector).appendChild(tz1Option);
    verify(timeZoneSelector).appendChild(tz2Option);
    verify(view).timeZoneSelectorRefresh();
}
Also used : HTMLOptionElement(elemental2.dom.HTMLOptionElement) DMNSimpleTimeZone(org.kie.workbench.common.dmn.api.editors.types.DMNSimpleTimeZone) Test(org.junit.Test)

Example 8 with HTMLOptionElement

use of elemental2.dom.HTMLOptionElement in project kie-wb-common by kiegroup.

the class TimeSelectorViewTest method testPopulateTimeZoneSelectorWithOffSets.

@Test
public void testPopulateTimeZoneSelectorWithOffSets() {
    final HTMLOptionElement noneOption = mock(HTMLOptionElement.class);
    final HTMLOptionElement option0 = mock(HTMLOptionElement.class);
    final HTMLOptionElement option1 = mock(HTMLOptionElement.class);
    final String os0 = "+01:00";
    final String os1 = "-03:00";
    final List<String> offsets = mock(List.class);
    when(offsets.size()).thenReturn(2);
    when(offsets.get(0)).thenReturn(os0);
    when(offsets.get(1)).thenReturn(os1);
    doReturn(noneOption).when(view).createNoneOption();
    doReturn(option0).when(view).createOptionWithOffset(os0);
    doReturn(option1).when(view).createOptionWithOffset(os1);
    doNothing().when(view).timeZoneSelectorRefresh();
    when(timeZoneProvider.getTimeZonesOffsets()).thenReturn(offsets);
    view.populateTimeZoneSelectorWithOffSets();
    verify(timeZoneSelector).appendChild(noneOption);
    verify(timeZoneSelector).appendChild(option0);
    verify(timeZoneSelector).appendChild(option1);
}
Also used : HTMLOptionElement(elemental2.dom.HTMLOptionElement) Test(org.junit.Test)

Example 9 with HTMLOptionElement

use of elemental2.dom.HTMLOptionElement in project kie-wb-common by kiegroup.

the class TimeSelectorViewTest method testCreateNoneOption.

@Test
public void testCreateNoneOption() {
    final HTMLOptionElement noneOption = new HTMLOptionElement();
    final String text = "text";
    when(translationService.getValue(NONE_TRANSLATION_KEY)).thenReturn(text);
    doReturn(noneOption).when(view).getNewOption();
    view.createNoneOption();
    assertEquals(NONE_VALUE, noneOption.value);
    assertEquals(text, noneOption.text);
}
Also used : HTMLOptionElement(elemental2.dom.HTMLOptionElement) Test(org.junit.Test)

Example 10 with HTMLOptionElement

use of elemental2.dom.HTMLOptionElement in project kie-wb-common by kiegroup.

the class KieAssetsDropdownView method entryOption.

protected HTMLOptionElement entryOption(final KieAssetsDropdownItem entry) {
    final HTMLOptionElement option = makeHTMLOptionElement();
    option.text = entry.getText();
    option.value = entry.getValue();
    option.setAttribute(SELECT_PICKER_SUBTEXT_ATTRIBUTE, entry.getSubText());
    return option;
}
Also used : HTMLOptionElement(elemental2.dom.HTMLOptionElement)

Aggregations

HTMLOptionElement (elemental2.dom.HTMLOptionElement)20 Test (org.junit.Test)11 HTMLOptGroupElement (elemental2.dom.HTMLOptGroupElement)3 DMNSimpleTimeZone (org.kie.workbench.common.dmn.api.editors.types.DMNSimpleTimeZone)3 DataType (org.kie.workbench.common.dmn.client.editors.types.common.DataType)3 Function (java.util.function.Function)2 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)2 Lists (org.kie.soup.commons.util.Lists)1 BuiltInType (org.kie.workbench.common.dmn.api.property.dmn.types.BuiltInType)1 DataTypeManager (org.kie.workbench.common.dmn.client.editors.types.common.DataTypeManager)1