1 import { FREQUENCY } from '../../../lib/calendar/constants';
2 import { getIsRruleEqual } from '../../../lib/calendar/recurrence/rruleEqual';
4 const getTest = (a, b, c, result) => ({
11 describe('rrule equal', () => {
13 getTest({ freq: FREQUENCY.ONCE }, undefined, false, false),
14 getTest({ freq: FREQUENCY.ONCE }, { freq: FREQUENCY.ONCE }, false, true),
15 getTest({ freq: FREQUENCY.ONCE }, { freq: FREQUENCY.WEEKLY }, false, false),
18 freq: FREQUENCY.MONTHLY,
22 freq: FREQUENCY.MONTHLY,
30 freq: FREQUENCY.MONTHLY,
34 freq: FREQUENCY.MONTHLY,
42 freq: FREQUENCY.MONTHLY,
46 freq: FREQUENCY.WEEKLY,
51 getTest({ count: 2 }, { count: 2 }, false, true),
52 getTest({ count: 2 }, { count: 3 }, false, false),
55 freq: FREQUENCY.WEEKLY,
59 freq: FREQUENCY.WEEKLY,
68 freq: FREQUENCY.WEEKLY,
76 freq: FREQUENCY.WEEKLY,
88 freq: FREQUENCY.WEEKLY,
96 freq: FREQUENCY.WEEKLY,
182 { freq: FREQUENCY.WEEKLY, byday: [1, 2, 3], interval: 2, wkst: 'SU' },
183 { freq: FREQUENCY.WEEKLY, byday: [1, 2, 3], interval: 2 },
188 { freq: FREQUENCY.WEEKLY, byday: [1, 2, 3], interval: 2, wkst: 'SU' },
189 { freq: FREQUENCY.WEEKLY, byday: [1, 2, 3], interval: 2 },
193 getTest({ bymonth: [1, 3, 2] }, { bymonth: [3, 2, 1] }, false, true),
194 getTest({}, { bymonth: [1, 3, 2] }, false, false),
195 getTest({ freq: FREQUENCY.WEEKLY, byday: [1] }, { freq: FREQUENCY.WEEKLY }, false, true),
196 getTest({ freq: FREQUENCY.WEEKLY, byday: [1], bymonth: [8] }, { freq: FREQUENCY.WEEKLY }, false, false),
197 getTest({ freq: FREQUENCY.MONTHLY, bymonthday: [13] }, { freq: FREQUENCY.MONTHLY }, false, true),
198 getTest({ freq: FREQUENCY.MONTHLY, bymonthday: [13], byday: [2] }, { freq: FREQUENCY.MONTHLY }, false, false),
199 getTest({ freq: FREQUENCY.YEARLY, byday: [7], bymonth: [7] }, { freq: FREQUENCY.YEARLY }, false, true),
200 getTest({ freq: FREQUENCY.YEARLY, byday: [7] }, { freq: FREQUENCY.YEARLY }, false, false),
201 ].forEach(({ a, b, c, result }, i) => {
202 it(`is rrule equal for ${i}`, () => {
203 expect(getIsRruleEqual({ value: a }, { value: b }, c)).toEqual(result);