1 import { FREQUENCY } from '../../../lib/calendar/constants';
2 import { withRruleUntil } from '../../../lib/calendar/recurrence/rruleUntil';
3 import { getDateProperty, getDateTimeProperty } from '../../../lib/calendar/vcalConverter';
4 import { fromLocalDate } from '../../../lib/date/timezone';
6 const getTest = (name, a, b, result) => ({
13 const getUntil = (date) => ({
14 ...fromLocalDate(date),
18 describe('rrule until', () => {
22 { freq: FREQUENCY.ONCE },
28 { freq: FREQUENCY.ONCE }
31 'convert from a date-time until to date if start is all day',
34 until: getUntil(new Date(2020, 1, 10, 12, 59, 59)),
36 getDateProperty({ year: 2020, month: 1, day: 1 }),
39 until: { year: 2020, month: 2, day: 10 },
43 'convert from a date until to date-time if start is part-day',
46 until: { year: 2020, month: 2, day: 10 },
48 getDateTimeProperty({ year: 2020, month: 1, day: 1, hours: 6, minutes: 12 }, 'Europe/Zurich'),
51 until: getUntil(new Date(2020, 1, 10, 22, 59, 59)),
55 'convert date-time timezone if start is part-day',
58 until: getUntil(new Date(2020, 1, 10, 22, 59, 59)),
60 getDateTimeProperty({ year: 2020, month: 1, day: 1, hours: 6, minutes: 12 }, 'UTC'),
63 until: getUntil(new Date(2020, 1, 10, 23, 59, 59)),
66 ].forEach(({ name, a, b, result }) => {
68 expect(withRruleUntil({ value: a }, b)).toEqual({ value: result });