use of com.vaadin.flow.component.timepicker.TimePicker in project flow-components by vaadin.
the class TimePickerTest method testSetStep_dividesEvenly_matchesGetter.
@Test
public void testSetStep_dividesEvenly_matchesGetter() {
TimePicker timePicker = new TimePicker();
assertEquals("Invalid default step", Duration.ofHours(1), timePicker.getStep());
timePicker.setStep(Duration.ofSeconds(1));
assertEquals("Invalid step returned", Duration.ofSeconds(1), timePicker.getStep());
timePicker.setStep(Duration.ofMillis(1));
assertEquals("Invalid step returned", Duration.ofMillis(1), timePicker.getStep());
timePicker.setStep(Duration.ofMillis(10));
assertEquals("Invalid step returned", Duration.ofMillis(10), timePicker.getStep());
timePicker.setStep(Duration.ofMillis(100));
assertEquals("Invalid step returned", Duration.ofMillis(100), timePicker.getStep());
timePicker.setStep(Duration.ofMillis(1000));
assertEquals("Invalid step returned", Duration.ofSeconds(1), timePicker.getStep());
// the next 3 would be broken in the web component
// https://github.com/vaadin/vaadin-time-picker/issues/79
timePicker.setStep(Duration.ofMinutes(40));
assertEquals("Invalid step returned", Duration.ofMinutes(40), timePicker.getStep());
timePicker.setStep(Duration.ofMinutes(45));
assertEquals("Invalid step returned", Duration.ofMinutes(45), timePicker.getStep());
timePicker.setStep(Duration.ofMinutes(90));
assertEquals("Invalid step returned", Duration.ofMinutes(90), timePicker.getStep());
}
use of com.vaadin.flow.component.timepicker.TimePicker in project flow-components by vaadin.
the class TimePickerTest method setMaxTime_getMax.
@Test
public void setMaxTime_getMax() {
TimePicker timePicker = new TimePicker();
final String max = "12:00";
LocalTime maxTime = LocalTime.parse(max);
timePicker.setMaxTime(maxTime);
assertEquals(maxTime, timePicker.getMax());
assertEquals(maxTime, timePicker.getMaxTime());
}
use of com.vaadin.flow.component.timepicker.TimePicker in project flow-components by vaadin.
the class TimePickerTest method timePicker_basicCases.
@Test
public void timePicker_basicCases() {
TimePicker picker = new TimePicker();
assertEquals(null, picker.getValue());
assertFalse(picker.getElement().hasProperty("value"));
picker.setValue(LocalTime.of(5, 30));
assertEquals("05:30", picker.getElement().getProperty("value"));
picker.getElement().setProperty("value", "07:40");
assertEquals(LocalTime.of(7, 40), picker.getValue());
}
use of com.vaadin.flow.component.timepicker.TimePicker in project flow-components by vaadin.
the class TimePickerTest method testSetStep_lessThan0Ms_throwsException.
@Test(expected = IllegalArgumentException.class)
public void testSetStep_lessThan0Ms_throwsException() {
TimePicker timePicker = new TimePicker();
timePicker.setStep(Duration.ofNanos(500_000));
}
use of com.vaadin.flow.component.timepicker.TimePicker in project flow-components by vaadin.
the class TimePickerTest method testSetStep_secondsNotDivideEvenly_throwsException.
@Test(expected = IllegalArgumentException.class)
public void testSetStep_secondsNotDivideEvenly_throwsException() {
TimePicker timePicker = new TimePicker();
timePicker.setStep(Duration.ofSeconds(11));
}
Aggregations