Merge branch 'feat/inda-383-daily-stat' into 'main'
[ProtonMail-WebClient.git] / packages / shared / test / calendar / rrule / rruleWkst.spec.js
blob21788131048d1a56fae4957ee13abead7d97d34d
1 import withVeventRruleWkst from '../../../lib/calendar/recurrence/rruleWkst';
3 describe('rrule wkst', () => {
4 it('should apply a wkst if it is relevant (weekly)', () => {
5 const vevent = {
6 component: 'vevent',
7 dtstart: {
8 value: { year: 2019, month: 7, day: 19, hours: 12, minutes: 0, seconds: 0, isUTC: false },
9 parameters: { tzid: 'America/New_York' },
11 summary: {
12 value: 'asd',
14 rrule: {
15 value: {
16 freq: 'WEEKLY',
17 byday: ['MO'],
18 interval: 2,
22 const newVevent = withVeventRruleWkst(vevent, 0);
23 expect(newVevent).toEqual({
24 component: 'vevent',
25 dtstart: {
26 value: { year: 2019, month: 7, day: 19, hours: 12, minutes: 0, seconds: 0, isUTC: false },
27 parameters: { tzid: 'America/New_York' },
29 summary: {
30 value: 'asd',
32 rrule: {
33 value: {
34 freq: 'WEEKLY',
35 byday: ['MO'],
36 interval: 2,
37 wkst: 'SU',
40 });
41 });
43 it('should apply a wkst if it is relevant (yearly)', () => {
44 const vevent = {
45 component: 'vevent',
46 rrule: {
47 value: {
48 freq: 'YEARLY',
49 byweekno: 1,
53 const newVevent = withVeventRruleWkst(vevent, 0);
54 expect(newVevent).toEqual({
55 component: 'vevent',
56 rrule: {
57 value: {
58 freq: 'YEARLY',
59 byweekno: 1,
60 wkst: 'SU',
63 });
64 });
66 it('should not apply a wkst if it is the default value', () => {
67 const vevent = {
68 component: 'vevent',
69 rrule: {
70 value: {
71 freq: 'WEEKLY',
72 byday: ['MO'],
73 interval: 2,
77 const newVevent = withVeventRruleWkst(vevent, 1);
78 expect(newVevent.rrule.value).toEqual({
79 freq: 'WEEKLY',
80 byday: ['MO'],
81 interval: 2,
82 });
83 });
85 it('should not apply a wkst if it is not needed', () => {
86 const vevent = {
87 component: 'vevent',
88 rrule: {
89 value: {
90 freq: 'WEEKLY',
91 interval: 2,
95 const newVevent = withVeventRruleWkst(vevent, 0);
96 expect(newVevent.rrule.value.wkst).toBeUndefined();
97 });
99 it('should not apply a wkst if it is not needed #2', () => {
100 const vevent = {
101 component: 'vevent',
102 rrule: {
103 value: {
104 freq: 'WEEKLY',
108 const newVevent = withVeventRruleWkst(vevent, 0);
109 expect(newVevent.rrule.value.wkst).toBeUndefined();
112 it('should remove wkst if it is not relevant', () => {
113 const vevent = {
114 component: 'vevent',
115 rrule: {
116 value: {
117 freq: 'WEEKLY',
118 byday: ['MO'],
119 interval: 2,
120 wkst: 'SU',
124 const newVevent = withVeventRruleWkst(vevent, 1);
125 expect(newVevent.rrule.value).toEqual({
126 freq: 'WEEKLY',
127 byday: ['MO'],
128 interval: 2,