aboutsummaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorSauli Tähkäpää <sauli@vaadin.com>2014-12-16 15:20:01 +0200
committerVaadin Code Review <review@vaadin.com>2014-12-19 09:37:55 +0000
commit65e69c1769ec18d4b7dacc89074d07aff8284b33 (patch)
tree7872a6b955a9cd212e23d59466c1770febefcb70 /server
parentbec1c92932b2e01b117e4aabffe3f0fe39ff07ae (diff)
downloadvaadin-framework-65e69c1769ec18d4b7dacc89074d07aff8284b33.tar.gz
vaadin-framework-65e69c1769ec18d4b7dacc89074d07aff8284b33.zip
Add DateFieldTest. (#15342)
Change-Id: I6cf033f060d90fba47242028ab4098020fa6b3dc
Diffstat (limited to 'server')
-rw-r--r--server/tests/src/com/vaadin/ui/DateFieldTests.java56
1 files changed, 56 insertions, 0 deletions
diff --git a/server/tests/src/com/vaadin/ui/DateFieldTests.java b/server/tests/src/com/vaadin/ui/DateFieldTests.java
new file mode 100644
index 0000000000..6a75b4630c
--- /dev/null
+++ b/server/tests/src/com/vaadin/ui/DateFieldTests.java
@@ -0,0 +1,56 @@
+package com.vaadin.ui;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import java.util.Date;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.IsNull.nullValue;
+
+public class DateFieldTests {
+
+ private DateField dateField;
+ private Date date;
+
+ @Before
+ public void setup() {
+ dateField = new DateField();
+ date = new Date();
+ }
+
+ @Test
+ public void rangeStartIsSetToNull() {
+ dateField.setRangeStart(null);
+
+ assertThat(dateField.getRangeStart(), is(nullValue()));
+ }
+
+ @Test
+ public void rangeStartIsImmutable() {
+ long expectedTime = date.getTime();
+
+ dateField.setRangeStart(date);
+ date.setTime(expectedTime + 1);
+
+ assertThat(dateField.getRangeStart().getTime(), is(expectedTime));
+ }
+
+ @Test
+ public void rangeEndIsSetToNull() {
+ dateField.setRangeEnd(null);
+
+ assertThat(dateField.getRangeEnd(), is(nullValue()));
+ }
+
+ @Test
+ public void rangeEndIsImmutable() {
+ long expectedTime = date.getTime();
+
+ dateField.setRangeEnd(date);
+ date.setTime(expectedTime + 1);
+
+ assertThat(dateField.getRangeEnd().getTime(), is(expectedTime));
+ }
+}