-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DatePattern now does not need a separator (but requires zero-prefixed day and month in that case)
- Loading branch information
1 parent
21a4e7e
commit e382394
Showing
7 changed files
with
200 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
superfields/src/test/java/org/vaadin/miki/shared/dates/DatePatternTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package org.vaadin.miki.shared.dates; | ||
|
||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
public class DatePatternTest { | ||
|
||
@Test | ||
public void noSeparatorMeansZeroPrefixedDayAndMonth() { | ||
final DatePattern pattern = new DatePattern().withZeroPrefixedDay(false).withZeroPrefixedMonth(false); | ||
Assert.assertTrue(pattern.hasSeparator()); | ||
pattern.withoutSeparator(); | ||
Assert.assertFalse(pattern.hasSeparator()); | ||
Assert.assertTrue("zero prefixed day must be set when there is no separator", pattern.isZeroPrefixedDay()); | ||
Assert.assertTrue("zero prefixed month must be set when there is no separator", pattern.isZeroPrefixedMonth()); | ||
} | ||
|
||
@Test | ||
public void turningOffZeroPrefixedDaySetsDefaultSeparatorWhenWasNone() { | ||
final DatePattern pattern = new DatePattern().withoutSeparator(); | ||
Assert.assertFalse(pattern.hasSeparator()); | ||
pattern.setZeroPrefixedDay(false); | ||
Assert.assertEquals("separator should be reverted to default", DatePattern.DEFAULT_SEPARATOR, pattern.getSeparator()); | ||
} | ||
|
||
@Test | ||
public void turningOffZeroPrefixedMonthSetsDefaultSeparatorWhenWasNone() { | ||
final DatePattern pattern = new DatePattern().withoutSeparator(); | ||
Assert.assertFalse(pattern.hasSeparator()); | ||
pattern.setZeroPrefixedMonth(false); | ||
Assert.assertEquals("separator should be reverted to default", DatePattern.DEFAULT_SEPARATOR, pattern.getSeparator()); | ||
} | ||
|
||
} |