Merge branch 'feat/inda-383-daily-stat' into 'main'
[ProtonMail-WebClient.git] / applications / calendar / src / app / components / eventModal / eventForm / getFrequencyModelChange.spec.js
blob25ed2c8684d991a7878e06caf389f898c68c7fb7
1 import { END_TYPE, FREQUENCY } from '@proton/shared/lib/calendar/constants';
3 import getFrequencyModelChange from './getFrequencyModelChange';
5 const frequencyModel = {
6     type: FREQUENCY.CUSTOM,
7     frequency: FREQUENCY.DAILY,
8     interval: 1,
9     daily: {
10         type: 0,
11     },
12     weekly: {
13         type: 0,
14         days: [4],
15     },
16     monthly: {
17         type: 0,
18     },
19     yearly: {
20         type: 0,
21     },
22     ends: {
23         type: END_TYPE.UNTIL,
24         count: 2,
25         until: new Date('2020-07-16T00:00:00.000Z'),
26     },
29 describe('Form update', () => {
30     it('should update end date if new start date is in the future', () => {
31         const newDate = new Date('2020-09-09T11:30:00.000Z');
32         const { ends } = getFrequencyModelChange(
33             {
34                 date: new Date('2020-05-16T00:00:00.000Z'),
35             },
36             {
37                 date: newDate,
38             },
39             frequencyModel
40         );
41         expect(+ends.until).toBe(+newDate);
42     });
43 });