Skip to content

Commit 29dacf5

Browse files
committed
Merge branch 'master' of github.com:wix/react-native-calendars into release
2 parents cbed31f + d06080c commit 29dacf5

File tree

5 files changed

+45
-4
lines changed

5 files changed

+45
-4
lines changed

src/dateutils.spec.js

+32
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,22 @@ describe('dateutils', function () {
7171
});
7272

7373
describe('isLTE()', function () {
74+
it('a is undefined', function () {
75+
const a = undefined;
76+
const b = XDate(2014, 1, 20);
77+
expect(isLTE(b, a)).toBe(undefined);
78+
});
79+
80+
it('b is undefined', function () {
81+
const a = XDate(2013, 12, 31);
82+
const b = undefined;
83+
expect(isLTE(b, a)).toBe(undefined);
84+
});
85+
86+
it('both are undefined', function () {
87+
expect(isLTE(undefined, undefined)).toBe(undefined);
88+
});
89+
7490
it('2014-01-20 >= 2013-12-31', function () {
7591
const a = XDate(2013, 12, 31);
7692
const b = XDate(2014, 1, 20);
@@ -98,6 +114,22 @@ describe('dateutils', function () {
98114
});
99115

100116
describe('isGTE()', function () {
117+
it('a is undefined', function () {
118+
const a = undefined;
119+
const b = XDate(2014, 1, 20);
120+
expect(isGTE(b, a)).toBe(undefined);
121+
});
122+
123+
it('b is undefined', function () {
124+
const a = XDate(2013, 12, 31);
125+
const b = undefined;
126+
expect(isGTE(b, a)).toBe(undefined);
127+
});
128+
129+
it('both are undefined', function () {
130+
expect(isGTE(undefined, undefined)).toBe(undefined);
131+
});
132+
101133
it('2014-01-20 >= 2013-12-31', function () {
102134
const a = XDate(2013, 12, 31);
103135
const b = XDate(2014, 1, 20);

src/dateutils.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,15 @@ export function isToday(date?: XDate | string) {
7878
}
7979

8080
export function isGTE(a: XDate, b: XDate) {
81-
return b.diffDays(a) > -1;
81+
if (a && b) {
82+
return b.diffDays(a) > -1;
83+
}
8284
}
8385

8486
export function isLTE(a: XDate, b: XDate) {
85-
return a.diffDays(b) > -1;
87+
if (a && b) {
88+
return a.diffDays(b) > -1;
89+
}
8690
}
8791

8892
export function formatNumbers(date: any) {

src/interface.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export function xdateToData(date: XDate | string) {
2020
}
2121

2222
export function parseDate(d?: any) {
23-
if (!d) {
23+
if (d === undefined) {
2424
return;
2525
} else if (d.timestamp) {
2626
// conventional data timestamp

src/timeline/Timeline.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,7 @@ const Timeline = (props: TimelineProps) => {
265265
width={width}
266266
numberOfDays={numberOfDays}
267267
timelineLeftInset={timelineLeftInset}
268+
testID={`${testID}.hours`}
268269
/>
269270
{times(numberOfDays, renderTimelineDay)}
270271
</ScrollView>

src/timeline/TimelineHours.tsx

+5-1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export interface TimelineHoursProps {
2727
width: number;
2828
numberOfDays: number;
2929
timelineLeftInset?: number;
30+
testID?: string;
3031
}
3132

3233
const dimensionWidth = constants.screenWidth;
@@ -45,7 +46,8 @@ const TimelineHours = (props: TimelineHoursProps) => {
4546
onBackgroundLongPressOut,
4647
width,
4748
numberOfDays = 1,
48-
timelineLeftInset = 0
49+
timelineLeftInset = 0,
50+
testID,
4951
} = props;
5052

5153
const lastLongPressEventTime = useRef<NewEventTime>();
@@ -121,12 +123,14 @@ const TimelineHours = (props: TimelineHoursProps) => {
121123
{time === start ? null : (
122124
<View
123125
key={`line${time}`}
126+
testID={`${testID}.${time}.line`}
124127
style={[styles.line, {top: offset * index, width: dimensionWidth - EVENT_DIFF, left: timelineLeftInset - 16}]}
125128
/>
126129
)}
127130
{
128131
<View
129132
key={`lineHalf${time}`}
133+
testID={`${testID}.${time}.lineHalf`}
130134
style={[styles.line, {top: offset * (index + 0.5), width: dimensionWidth - EVENT_DIFF, left: timelineLeftInset - 16}]}
131135
/>
132136
}

0 commit comments

Comments
 (0)