diff --git a/examples/detox/e2e/tests/timezoneOffset.spec.js b/examples/detox/e2e/tests/timezoneOffset.spec.js new file mode 100644 index 0000000..469a47d --- /dev/null +++ b/examples/detox/e2e/tests/timezoneOffset.spec.js @@ -0,0 +1,81 @@ +const { + setTimeZoneOffsetInMinutes, + expectDate, + scrollWheel, + expectDateString, + setMaximumDate, + setDate, +} = require('../utils') + +const scrollMinuteWheel = () => scrollWheel(2, 1) + +// I haven't found a way to change the timezone on the emulator to be able to run these tests. +// Until possible, run these tests locally when needed with Europe/Stockholm timezone. +describe.skip('Timezone offset', () => { + before(async () => { + await device.reloadReactNative() + await element(by.text('Advanced')).tap() + }) + + it('undefined (default)', async () => { + await setTimeZoneOffsetInMinutes(undefined) + await scrollMinuteWheel() + await expectDate('2000-01-01 00:01:00') + await expectDateString('Sat Jan 11201 AM ') + }) + + it('0', async () => { + await setTimeZoneOffsetInMinutes(0) + await scrollMinuteWheel() + await expectDate('2000-01-01 00:01:00') + await expectDateString('Fri Dec 311101 PM ') + }) + + it('180', async () => { + await setTimeZoneOffsetInMinutes(180) + await scrollMinuteWheel() + await expectDate('2000-01-01 00:01:00') + await expectDateString('Sat Jan 1201 AM ') + }) + + it('-180', async () => { + await setTimeZoneOffsetInMinutes(-180) + await scrollMinuteWheel() + await expectDate('2000-01-01 00:01:00') + await expectDateString('Fri Dec 31801 PM ') + }) + + describe('daylight saving', () => { + const firstOfJuly = new Date(2000, 6, 1, 0, 0) + const firstOfJune = new Date(2000, 5, 1, 0, 0) + + before(async () => { + await setMaximumDate(firstOfJuly) + await setDate(firstOfJune) + }) + + it('undefined', async () => { + await setDate(firstOfJune) + await setTimeZoneOffsetInMinutes(undefined) + await scrollMinuteWheel() + await expectDate('2000-06-01 00:01:00') + await expectDateString('Thu Jun 11201 AM ') + }) + + it('0', async () => { + await setDate(firstOfJune) + await setTimeZoneOffsetInMinutes(0) + await scrollMinuteWheel() + await expectDate('2000-06-01 00:01:00') + await expectDateString('Wed May 311001 PM ') + }) + + it('180', async () => { + await setDate(firstOfJune) + await setTimeZoneOffsetInMinutes(180) + await scrollMinuteWheel() + await expectDate('2000-06-01 00:01:00') + await expectDateString('Thu Jun 1101 AM ') + }) + }) +}) diff --git a/examples/detox/e2e/utils.js b/examples/detox/e2e/utils.js index c7e73e5..9b29ae0 100644 --- a/examples/detox/e2e/utils.js +++ b/examples/detox/e2e/utils.js @@ -35,6 +35,7 @@ exports.setLocale = changeProp('locale') exports.setMinimumDate = changeProp('minimumDate') exports.setMaximumDate = changeProp('maximumDate') exports.setMinuteInterval = changeProp('minuteInterval') +exports.setTimeZoneOffsetInMinutes = changeProp('timeZoneOffsetInMinutes') exports.setMode = changeProp('mode') exports.scrollWheel = scrollWheel exports.expectDate = expectDate diff --git a/examples/detox/src/CustomPropValue.js b/examples/detox/src/CustomPropValue.js index 0309286..25cd537 100644 --- a/examples/detox/src/CustomPropValue.js +++ b/examples/detox/src/CustomPropValue.js @@ -8,6 +8,7 @@ export default function CustomPropValue(props) { const getPropValue = () => { if (propValue === "undefined") return undefined if (propName === "minuteInterval") return parseInt(propValue) + if (propName === "timeZoneOffsetInMinutes") return parseInt(propValue) if (["date", "maximumDate", "minimumDate"].includes(propName)) return new Date(propValue) return propValue } diff --git a/examples/detox/src/propPickers/DateChange.js b/examples/detox/src/propPickers/DateChange.js index 74e25b8..05f0f6f 100644 --- a/examples/detox/src/propPickers/DateChange.js +++ b/examples/detox/src/propPickers/DateChange.js @@ -13,7 +13,6 @@ export default class extends Component { ) } /> -