forked from henninghall/react-native-date-picker
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bugfix: Scroll away from invalid dates (henninghall#280)
* initial working version * fix native variant issue * cleanup * cleanup
- Loading branch information
1 parent
5547b72
commit 26f7316
Showing
5 changed files
with
172 additions
and
29 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
const { scrollWheel, expectDate, setDate, setMode, setMaximumDate, setMinimumDate } = require('../utils') | ||
|
||
const scrollDays = (days) => scrollWheel(1, days) | ||
|
||
describe('Invalid dates', () => { | ||
before(async () => { | ||
await device.reloadReactNative() | ||
await element(by.text('Advanced')).tap() | ||
await setMinimumDate(undefined) | ||
await setMaximumDate(undefined) | ||
await setMode('date') | ||
}) | ||
|
||
|
||
it('scrolls back to last valid date', async () => { | ||
await setDate(new Date("2001-02-28 00:00")) | ||
await scrollDays(1) | ||
await expectDate('2001-02-28 00:00:00') | ||
}) | ||
|
||
it('scrolls back after scrolling multiple dates', async () => { | ||
await setDate(new Date("2001-02-27 00:00")) | ||
await scrollDays(2) | ||
await expectDate('2001-02-28 00:00:00') | ||
}) | ||
|
||
it('not scrolling back on unusual valid dates', async () => { | ||
await setDate(new Date("2000-02-28 00:00")) | ||
await scrollDays(1) | ||
await expectDate('2000-02-29 00:00:00') | ||
}) | ||
|
||
it('not scrolling back after scrolling past invalid dates', async () => { | ||
await setDate(new Date("2001-02-28 00:00")) | ||
await scrollDays(4) | ||
await expectDate('2001-02-01 00:00:00') | ||
}) | ||
|
||
it('works on months with 30 days', async () => { | ||
await setDate(new Date("2001-04-30 00:00")) | ||
await scrollDays(1) | ||
await expectDate('2001-04-30 00:00:00') | ||
}) | ||
|
||
it('works on months with 31 days', async () => { | ||
await setDate(new Date("2001-05-30 00:00")) | ||
await scrollDays(1) | ||
await expectDate('2001-05-31 00:00:00') | ||
}) | ||
|
||
|
||
}) |