From a46b9e605bf2a5ee9196b326677ad0b1b7231a91 Mon Sep 17 00:00:00 2001 From: Inbal Tish <33805983+Inbal-Tish@users.noreply.github.com> Date: Tue, 13 Feb 2024 10:18:57 +0200 Subject: [PATCH 1/3] toMarkingFormat - Cannot convert undefined value to object (#2409) --- src/interface.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/interface.ts b/src/interface.ts index 14ab054eb0..055743bed4 100644 --- a/src/interface.ts +++ b/src/interface.ts @@ -20,7 +20,7 @@ export function xdateToData(date: XDate | string) { } export function parseDate(d?: any) { - if (!d) { + if (d === undefined) { return; } else if (d.timestamp) { // conventional data timestamp From 2922d3b010228d6dd3f8d16c06d56ce8843d8314 Mon Sep 17 00:00:00 2001 From: yuvalsho <49347352+yuvalsho@users.noreply.github.com> Date: Tue, 13 Feb 2024 14:14:13 +0200 Subject: [PATCH 2/3] add testIDs for timeline lines (#2402) --- src/timeline/Timeline.tsx | 1 + src/timeline/TimelineHours.tsx | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/timeline/Timeline.tsx b/src/timeline/Timeline.tsx index 4072096f5e..e2140ce86a 100644 --- a/src/timeline/Timeline.tsx +++ b/src/timeline/Timeline.tsx @@ -265,6 +265,7 @@ const Timeline = (props: TimelineProps) => { width={width} numberOfDays={numberOfDays} timelineLeftInset={timelineLeftInset} + testID={`${testID}.hours`} /> {times(numberOfDays, renderTimelineDay)} diff --git a/src/timeline/TimelineHours.tsx b/src/timeline/TimelineHours.tsx index 2bec2cacc8..f0366d6f9d 100644 --- a/src/timeline/TimelineHours.tsx +++ b/src/timeline/TimelineHours.tsx @@ -27,6 +27,7 @@ export interface TimelineHoursProps { width: number; numberOfDays: number; timelineLeftInset?: number; + testID?: string; } const dimensionWidth = constants.screenWidth; @@ -45,7 +46,8 @@ const TimelineHours = (props: TimelineHoursProps) => { onBackgroundLongPressOut, width, numberOfDays = 1, - timelineLeftInset = 0 + timelineLeftInset = 0, + testID, } = props; const lastLongPressEventTime = useRef(); @@ -121,12 +123,14 @@ const TimelineHours = (props: TimelineHoursProps) => { {time === start ? null : ( )} { } From d06080c54364062080a95dd05ab7324acab98f94 Mon Sep 17 00:00:00 2001 From: Inbal Tish <33805983+Inbal-Tish@users.noreply.github.com> Date: Wed, 14 Feb 2024 15:07:03 +0200 Subject: [PATCH 3/3] Secure isLTE and isGTE functions (#2410) --- src/dateutils.spec.js | 32 ++++++++++++++++++++++++++++++++ src/dateutils.ts | 8 ++++++-- 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/src/dateutils.spec.js b/src/dateutils.spec.js index 3ee87d33bc..261ee36e79 100644 --- a/src/dateutils.spec.js +++ b/src/dateutils.spec.js @@ -71,6 +71,22 @@ describe('dateutils', function () { }); describe('isLTE()', function () { + it('a is undefined', function () { + const a = undefined; + const b = XDate(2014, 1, 20); + expect(isLTE(b, a)).toBe(undefined); + }); + + it('b is undefined', function () { + const a = XDate(2013, 12, 31); + const b = undefined; + expect(isLTE(b, a)).toBe(undefined); + }); + + it('both are undefined', function () { + expect(isLTE(undefined, undefined)).toBe(undefined); + }); + it('2014-01-20 >= 2013-12-31', function () { const a = XDate(2013, 12, 31); const b = XDate(2014, 1, 20); @@ -98,6 +114,22 @@ describe('dateutils', function () { }); describe('isGTE()', function () { + it('a is undefined', function () { + const a = undefined; + const b = XDate(2014, 1, 20); + expect(isGTE(b, a)).toBe(undefined); + }); + + it('b is undefined', function () { + const a = XDate(2013, 12, 31); + const b = undefined; + expect(isGTE(b, a)).toBe(undefined); + }); + + it('both are undefined', function () { + expect(isGTE(undefined, undefined)).toBe(undefined); + }); + it('2014-01-20 >= 2013-12-31', function () { const a = XDate(2013, 12, 31); const b = XDate(2014, 1, 20); diff --git a/src/dateutils.ts b/src/dateutils.ts index 815283dd6e..14d427fca7 100644 --- a/src/dateutils.ts +++ b/src/dateutils.ts @@ -78,11 +78,15 @@ export function isToday(date?: XDate | string) { } export function isGTE(a: XDate, b: XDate) { - return b.diffDays(a) > -1; + if (a && b) { + return b.diffDays(a) > -1; + } } export function isLTE(a: XDate, b: XDate) { - return a.diffDays(b) > -1; + if (a && b) { + return a.diffDays(b) > -1; + } } export function formatNumbers(date: any) {