@@ -364,3 +364,94 @@ it('ToDoComponent should provide access methods for CONFERENCE', () => {
364364 expect ( component . getConferenceList ( ) . length ) . toEqual ( 0 )
365365 expect ( component . getConferenceList ( ) ) . toEqual ( [ ] )
366366} )
367+
368+ it . each ( [
369+ [
370+ 'none' ,
371+ undefined ,
372+ undefined ,
373+ undefined ,
374+ true ,
375+ true ,
376+ true ,
377+ true ,
378+ ] ,
379+ [
380+ 'DTSTART only' ,
381+ DateTimeValue . fromJSDate ( new Date ( '2025-01-01T10:30:00Z' ) ) ,
382+ undefined ,
383+ undefined ,
384+ false ,
385+ true ,
386+ true ,
387+ true ,
388+ ] ,
389+ [
390+ 'DTSTART and DUE' ,
391+ DateTimeValue . fromJSDate ( new Date ( '2025-01-01T10:30:00Z' ) ) ,
392+ undefined ,
393+ DateTimeValue . fromJSDate ( new Date ( '2025-01-01T10:50:00Z' ) ) ,
394+ false ,
395+ true ,
396+ false ,
397+ false ,
398+ ] ,
399+ [
400+ 'DTSTART and DUE (overlapping)' ,
401+ DateTimeValue . fromJSDate ( new Date ( '2025-01-01T10:30:00Z' ) ) ,
402+ undefined ,
403+ DateTimeValue . fromJSDate ( new Date ( '2025-01-01T11:50:00Z' ) ) ,
404+ false ,
405+ true ,
406+ true ,
407+ false ,
408+ ] ,
409+ [
410+ 'DTSTART and DURATION' ,
411+ DateTimeValue . fromJSDate ( new Date ( '2025-01-01T10:30:00Z' ) ) ,
412+ DurationValue . fromSeconds ( 900 ) ,
413+ undefined ,
414+ false ,
415+ true ,
416+ false ,
417+ false ,
418+ ] ,
419+ [
420+ 'DTSTART and DURATION (overlapping)' ,
421+ DateTimeValue . fromJSDate ( new Date ( '2025-01-01T10:30:00Z' ) ) ,
422+ DurationValue . fromSeconds ( 3600 ) ,
423+ undefined ,
424+ false ,
425+ true ,
426+ true ,
427+ false ,
428+ ] ,
429+ ] ) ( 'ToDoComponent should report being inside a time frame - %s' , ( name , dtstart , duration , due , expectInTimeFrame1 , expectInTimeFrame2 , expectInTimeFrame3 , expectInTimeFrame4 ) => {
430+ const component = new ToDoComponent ( 'VTODO' )
431+
432+ if ( dtstart ) {
433+ component . addProperty ( new Property ( 'dtstart' , dtstart ) )
434+ }
435+ if ( duration ) {
436+ component . addProperty ( new Property ( 'duration' , duration ) )
437+ }
438+ if ( due ) {
439+ component . addProperty ( new Property ( 'due' , due ) )
440+ }
441+
442+ const date1 = DateTimeValue . fromJSDate ( new Date ( '2025-01-01T09:00:00Z' ) )
443+ const date2 = DateTimeValue . fromJSDate ( new Date ( '2025-01-01T09:59:59Z' ) )
444+ expect ( component . isInTimeFrame ( date1 , date2 ) ) . toEqual ( expectInTimeFrame1 )
445+
446+ const date3 = DateTimeValue . fromJSDate ( new Date ( '2025-01-01T10:00:00Z' ) )
447+ const date4 = DateTimeValue . fromJSDate ( new Date ( '2025-01-01T10:59:59Z' ) )
448+ expect ( component . isInTimeFrame ( date3 , date4 ) ) . toEqual ( expectInTimeFrame2 )
449+
450+ const date5 = DateTimeValue . fromJSDate ( new Date ( '2025-01-01T11:00:00Z' ) )
451+ const date6 = DateTimeValue . fromJSDate ( new Date ( '2025-01-01T11:59:59Z' ) )
452+ expect ( component . isInTimeFrame ( date5 , date6 ) ) . toEqual ( expectInTimeFrame3 )
453+
454+ const date7 = DateTimeValue . fromJSDate ( new Date ( '2025-01-01T12:00:00Z' ) )
455+ const date8 = DateTimeValue . fromJSDate ( new Date ( '2025-01-01T13:00:00Z' ) )
456+ expect ( component . isInTimeFrame ( date7 , date8 ) ) . toEqual ( expectInTimeFrame4 )
457+ } )
0 commit comments