Merge branch 'IDTEAM-1.26.0' into 'main'
[ProtonMail-WebClient.git] / packages / shared / test / calendar / calendarLimits.spec.ts
blobb022d5290b959bfd79eda0f4340a4a8da54fac38
1 import {
2     generateOwnedPersonalCalendars,
3     generateSharedCalendars,
4     generateSubscribedCalendars,
5 } from '@proton/testing/lib/builders';
7 import { getHasUserReachedCalendarsLimit, willUserReachCalendarsLimit } from '../../lib/calendar/calendarLimits';
8 import { MAX_CALENDARS_FREE, MAX_CALENDARS_PAID } from '../../lib/calendar/constants';
10 describe('getHasUserReachedCalendarLimit()', () => {
11     describe('informs whether the calendar limits for a free user have been reached', () => {
12         [
13             // owned calendars
14             {
15                 calendars: generateOwnedPersonalCalendars(MAX_CALENDARS_FREE - 1),
16                 isFreeUser: true,
17                 result: {
18                     isCalendarsLimitReached: false,
19                     isOtherCalendarsLimitReached: false,
20                 },
21             },
22             {
23                 calendars: generateOwnedPersonalCalendars(MAX_CALENDARS_FREE),
24                 isFreeUser: true,
25                 result: {
26                     isCalendarsLimitReached: true,
27                     isOtherCalendarsLimitReached: true,
28                 },
29             },
30             {
31                 calendars: generateOwnedPersonalCalendars(MAX_CALENDARS_FREE + 1),
32                 isFreeUser: true,
33                 result: {
34                     isCalendarsLimitReached: true,
35                     isOtherCalendarsLimitReached: true,
36                 },
37             },
38             // shared calendars
39             {
40                 calendars: generateSharedCalendars(MAX_CALENDARS_FREE - 1),
41                 isFreeUser: true,
42                 result: {
43                     isCalendarsLimitReached: false,
44                     isOtherCalendarsLimitReached: true,
45                 },
46             },
47             {
48                 calendars: generateSharedCalendars(MAX_CALENDARS_FREE),
49                 isFreeUser: true,
50                 result: {
51                     isCalendarsLimitReached: false,
52                     isOtherCalendarsLimitReached: true,
53                 },
54             },
55             {
56                 calendars: generateSharedCalendars(MAX_CALENDARS_FREE + 1),
57                 isFreeUser: true,
58                 result: {
59                     isCalendarsLimitReached: false,
60                     isOtherCalendarsLimitReached: true,
61                 },
62             },
63             // subscribed calendars
64             {
65                 calendars: generateSubscribedCalendars(MAX_CALENDARS_FREE - 1),
66                 isFreeUser: true,
67                 result: {
68                     isCalendarsLimitReached: false,
69                     isOtherCalendarsLimitReached: true,
70                 },
71             },
72             {
73                 calendars: generateSubscribedCalendars(MAX_CALENDARS_FREE),
74                 isFreeUser: true,
75                 result: {
76                     isCalendarsLimitReached: false,
77                     isOtherCalendarsLimitReached: true,
78                 },
79             },
80             {
81                 calendars: generateSubscribedCalendars(MAX_CALENDARS_FREE + 1),
82                 isFreeUser: true,
83                 result: {
84                     isCalendarsLimitReached: false,
85                     isOtherCalendarsLimitReached: true,
86                 },
87             },
88             // shared and owned personal
89             {
90                 calendars: [...generateOwnedPersonalCalendars(1), ...generateSharedCalendars(MAX_CALENDARS_FREE - 1)],
91                 isFreeUser: true,
92                 result: {
93                     isCalendarsLimitReached: true,
94                     isOtherCalendarsLimitReached: true,
95                 },
96             },
97             {
98                 calendars: [...generateOwnedPersonalCalendars(2), ...generateSharedCalendars(MAX_CALENDARS_FREE - 2)],
99                 isFreeUser: true,
100                 result: {
101                     isCalendarsLimitReached: true,
102                     isOtherCalendarsLimitReached: true,
103                 },
104             },
105             {
106                 calendars: [...generateOwnedPersonalCalendars(1), ...generateSharedCalendars(MAX_CALENDARS_FREE)],
107                 isFreeUser: true,
108                 result: {
109                     isCalendarsLimitReached: true,
110                     isOtherCalendarsLimitReached: true,
111                 },
112             },
113             // subscribed and owned personal
114             {
115                 calendars: [
116                     ...generateOwnedPersonalCalendars(1),
117                     ...generateSubscribedCalendars(MAX_CALENDARS_FREE - 1),
118                 ],
119                 isFreeUser: true,
120                 result: {
121                     isCalendarsLimitReached: true,
122                     isOtherCalendarsLimitReached: true,
123                 },
124             },
125             {
126                 calendars: [
127                     ...generateOwnedPersonalCalendars(2),
128                     ...generateSubscribedCalendars(MAX_CALENDARS_FREE - 2),
129                 ],
130                 isFreeUser: true,
131                 result: {
132                     isCalendarsLimitReached: true,
133                     isOtherCalendarsLimitReached: true,
134                 },
135             },
136             {
137                 calendars: [...generateOwnedPersonalCalendars(1), ...generateSubscribedCalendars(MAX_CALENDARS_FREE)],
138                 isFreeUser: true,
139                 result: {
140                     isCalendarsLimitReached: true,
141                     isOtherCalendarsLimitReached: true,
142                 },
143             },
144             // subscribed and shared
145             {
146                 calendars: [...generateSharedCalendars(1), ...generateSubscribedCalendars(1)],
147                 isFreeUser: true,
148                 result: {
149                     isCalendarsLimitReached: false,
150                     isOtherCalendarsLimitReached: true,
151                 },
152             },
153             {
154                 calendars: [...generateSharedCalendars(1), ...generateSubscribedCalendars(MAX_CALENDARS_FREE - 2)],
155                 isFreeUser: true,
156                 result: {
157                     isCalendarsLimitReached: false,
158                     isOtherCalendarsLimitReached: true,
159                 },
160             },
161             {
162                 calendars: [...generateSharedCalendars(MAX_CALENDARS_FREE - 2), ...generateSubscribedCalendars(1)],
163                 isFreeUser: true,
164                 result: {
165                     isCalendarsLimitReached: false,
166                     isOtherCalendarsLimitReached: true,
167                 },
168             },
169             {
170                 calendars: [...generateSubscribedCalendars(2), ...generateSharedCalendars(MAX_CALENDARS_FREE - 2)],
171                 isFreeUser: true,
172                 result: {
173                     isCalendarsLimitReached: false,
174                     isOtherCalendarsLimitReached: true,
175                 },
176             },
177             {
178                 calendars: [...generateSharedCalendars(1), ...generateSubscribedCalendars(MAX_CALENDARS_FREE)],
179                 isFreeUser: true,
180                 result: {
181                     isCalendarsLimitReached: false,
182                     isOtherCalendarsLimitReached: true,
183                 },
184             },
185             // all
186             {
187                 calendars: [
188                     ...generateOwnedPersonalCalendars(1),
189                     ...generateSharedCalendars(1),
190                     ...generateSubscribedCalendars(1),
191                 ],
192                 isFreeUser: true,
193                 result: {
194                     isCalendarsLimitReached: true,
195                     isOtherCalendarsLimitReached: true,
196                 },
197             },
198             {
199                 calendars: [
200                     ...generateOwnedPersonalCalendars(1),
201                     ...generateSharedCalendars(2),
202                     ...generateSubscribedCalendars(3),
203                 ],
204                 isFreeUser: true,
205                 result: {
206                     isCalendarsLimitReached: true,
207                     isOtherCalendarsLimitReached: true,
208                 },
209             },
210         ].forEach(({ calendars, isFreeUser, result }, i) => {
211             it(`is limit reached for case ${i + 1}`, () => {
212                 expect(getHasUserReachedCalendarsLimit(calendars, isFreeUser)).toEqual(result);
213             });
214         });
215     });
217     describe('informs whether the calendar limits for a paid user have been reached', () => {
218         [
219             // owned calendars
220             {
221                 calendars: generateOwnedPersonalCalendars(MAX_CALENDARS_PAID - 1),
222                 isFreeUser: false,
223                 result: {
224                     isCalendarsLimitReached: false,
225                     isOtherCalendarsLimitReached: false,
226                 },
227             },
228             {
229                 calendars: generateOwnedPersonalCalendars(MAX_CALENDARS_PAID),
230                 isFreeUser: false,
231                 result: {
232                     isCalendarsLimitReached: true,
233                     isOtherCalendarsLimitReached: true,
234                 },
235             },
236             {
237                 calendars: generateOwnedPersonalCalendars(MAX_CALENDARS_PAID + 1),
238                 isFreeUser: false,
239                 result: {
240                     isCalendarsLimitReached: true,
241                     isOtherCalendarsLimitReached: true,
242                 },
243             },
244             // shared calendars
245             {
246                 calendars: generateSharedCalendars(MAX_CALENDARS_PAID - 1),
247                 isFreeUser: false,
248                 result: {
249                     isCalendarsLimitReached: false,
250                     isOtherCalendarsLimitReached: true,
251                 },
252             },
253             {
254                 calendars: generateSharedCalendars(MAX_CALENDARS_PAID),
255                 isFreeUser: false,
256                 result: {
257                     isCalendarsLimitReached: false,
258                     isOtherCalendarsLimitReached: true,
259                 },
260             },
261             {
262                 calendars: generateSharedCalendars(MAX_CALENDARS_PAID + 1),
263                 isFreeUser: false,
264                 result: {
265                     isCalendarsLimitReached: false,
266                     isOtherCalendarsLimitReached: true,
267                 },
268             },
269             // subscribed calendars
270             {
271                 calendars: generateSubscribedCalendars(MAX_CALENDARS_PAID - 1),
272                 isFreeUser: false,
273                 result: {
274                     isCalendarsLimitReached: false,
275                     isOtherCalendarsLimitReached: true,
276                 },
277             },
278             {
279                 calendars: generateSubscribedCalendars(MAX_CALENDARS_PAID),
280                 isFreeUser: false,
281                 result: {
282                     isCalendarsLimitReached: false,
283                     isOtherCalendarsLimitReached: true,
284                 },
285             },
286             {
287                 calendars: generateSubscribedCalendars(MAX_CALENDARS_PAID + 1),
288                 isFreeUser: false,
289                 result: {
290                     isCalendarsLimitReached: false,
291                     isOtherCalendarsLimitReached: true,
292                 },
293             },
294             // shared and owned personal
295             {
296                 calendars: [...generateOwnedPersonalCalendars(1), ...generateSharedCalendars(MAX_CALENDARS_PAID - 1)],
297                 isFreeUser: false,
298                 result: {
299                     isCalendarsLimitReached: true,
300                     isOtherCalendarsLimitReached: true,
301                 },
302             },
303             {
304                 calendars: [...generateOwnedPersonalCalendars(2), ...generateSharedCalendars(MAX_CALENDARS_PAID - 2)],
305                 isFreeUser: false,
306                 result: {
307                     isCalendarsLimitReached: true,
308                     isOtherCalendarsLimitReached: true,
309                 },
310             },
311             {
312                 calendars: [...generateOwnedPersonalCalendars(1), ...generateSharedCalendars(MAX_CALENDARS_PAID)],
313                 isFreeUser: false,
314                 result: {
315                     isCalendarsLimitReached: true,
316                     isOtherCalendarsLimitReached: true,
317                 },
318             },
319             // subscribed and owned personal
320             {
321                 calendars: [
322                     ...generateOwnedPersonalCalendars(1),
323                     ...generateSubscribedCalendars(MAX_CALENDARS_PAID - 1),
324                 ],
325                 isFreeUser: false,
326                 result: {
327                     isCalendarsLimitReached: true,
328                     isOtherCalendarsLimitReached: true,
329                 },
330             },
331             {
332                 calendars: [
333                     ...generateOwnedPersonalCalendars(2),
334                     ...generateSubscribedCalendars(MAX_CALENDARS_PAID - 2),
335                 ],
336                 isFreeUser: false,
337                 result: {
338                     isCalendarsLimitReached: true,
339                     isOtherCalendarsLimitReached: true,
340                 },
341             },
342             {
343                 calendars: [...generateOwnedPersonalCalendars(1), ...generateSubscribedCalendars(MAX_CALENDARS_PAID)],
344                 isFreeUser: false,
345                 result: {
346                     isCalendarsLimitReached: true,
347                     isOtherCalendarsLimitReached: true,
348                 },
349             },
350             // subscribed and shared
351             {
352                 calendars: [...generateSharedCalendars(1), ...generateSubscribedCalendars(MAX_CALENDARS_PAID - 3)],
353                 isFreeUser: false,
354                 result: {
355                     isCalendarsLimitReached: false,
356                     isOtherCalendarsLimitReached: false,
357                 },
358             },
359             {
360                 calendars: [...generateSharedCalendars(MAX_CALENDARS_PAID - 3), ...generateSubscribedCalendars(1)],
361                 isFreeUser: false,
362                 result: {
363                     isCalendarsLimitReached: false,
364                     isOtherCalendarsLimitReached: false,
365                 },
366             },
367             {
368                 calendars: [...generateSharedCalendars(1), ...generateSubscribedCalendars(MAX_CALENDARS_PAID - 2)],
369                 isFreeUser: false,
370                 result: {
371                     isCalendarsLimitReached: false,
372                     isOtherCalendarsLimitReached: true,
373                 },
374             },
375             {
376                 calendars: [...generateSharedCalendars(MAX_CALENDARS_PAID - 2), ...generateSubscribedCalendars(1)],
377                 isFreeUser: false,
378                 result: {
379                     isCalendarsLimitReached: false,
380                     isOtherCalendarsLimitReached: true,
381                 },
382             },
383             {
384                 calendars: [...generateSubscribedCalendars(2), ...generateSharedCalendars(MAX_CALENDARS_PAID - 2)],
385                 isFreeUser: false,
386                 result: {
387                     isCalendarsLimitReached: false,
388                     isOtherCalendarsLimitReached: true,
389                 },
390             },
391             {
392                 calendars: [...generateSharedCalendars(1), ...generateSubscribedCalendars(MAX_CALENDARS_PAID)],
393                 isFreeUser: false,
394                 result: {
395                     isCalendarsLimitReached: false,
396                     isOtherCalendarsLimitReached: true,
397                 },
398             },
399             // all
400             {
401                 calendars: [
402                     ...generateOwnedPersonalCalendars(MAX_CALENDARS_PAID - 5),
403                     ...generateSharedCalendars(2),
404                     ...generateSubscribedCalendars(2),
405                 ],
406                 isFreeUser: false,
407                 result: {
408                     isCalendarsLimitReached: false,
409                     isOtherCalendarsLimitReached: false,
410                 },
411             },
412             {
413                 calendars: [
414                     ...generateOwnedPersonalCalendars(MAX_CALENDARS_PAID - 5),
415                     ...generateSharedCalendars(2),
416                     ...generateSubscribedCalendars(3),
417                 ],
418                 isFreeUser: false,
419                 result: {
420                     isCalendarsLimitReached: true,
421                     isOtherCalendarsLimitReached: true,
422                 },
423             },
424             {
425                 calendars: [...generateSharedCalendars(MAX_CALENDARS_PAID - 3), ...generateSubscribedCalendars(2)],
426                 isFreeUser: false,
427                 result: {
428                     isCalendarsLimitReached: false,
429                     isOtherCalendarsLimitReached: true,
430                 },
431             },
432         ].forEach(({ calendars, isFreeUser, result }, i) => {
433             it(`is limit reached for case ${i + 1}`, () => {
434                 expect(getHasUserReachedCalendarsLimit(calendars, isFreeUser)).toEqual(result);
435             });
436         });
437     });
440 describe('willUserReachCalendarsLimit()', () => {
441     describe('informs whether the calendar limits for a free user will be reached from easy switch', () => {
442         [
443             // owned calendars
444             {
445                 number: 1,
446                 calendars: generateOwnedPersonalCalendars(MAX_CALENDARS_FREE - 2),
447                 isFreeUser: true,
448                 result: false,
449             },
450             {
451                 number: 1,
452                 calendars: generateOwnedPersonalCalendars(MAX_CALENDARS_FREE),
453                 isFreeUser: true,
454                 result: true,
455             },
456             {
457                 number: 1,
458                 calendars: generateOwnedPersonalCalendars(MAX_CALENDARS_FREE + 1),
459                 isFreeUser: true,
460                 result: true,
461             },
463             {
464                 number: 1,
465                 calendars: generateSharedCalendars(MAX_CALENDARS_FREE - 1),
466                 isFreeUser: true,
467                 result: false,
468             },
469             {
470                 number: 1,
471                 calendars: generateSharedCalendars(MAX_CALENDARS_FREE),
472                 isFreeUser: true,
473                 result: true,
474             },
475             {
476                 number: 1,
477                 calendars: generateSharedCalendars(MAX_CALENDARS_FREE + 1),
478                 isFreeUser: true,
479                 result: true,
480             },
481             // subscribed calendars
482             {
483                 number: 1,
484                 calendars: generateSubscribedCalendars(MAX_CALENDARS_FREE - 1),
485                 isFreeUser: true,
486                 result: false,
487             },
488             {
489                 number: 1,
490                 calendars: generateSubscribedCalendars(MAX_CALENDARS_FREE),
491                 isFreeUser: true,
492                 result: true,
493             },
494             {
495                 number: 1,
496                 calendars: generateSubscribedCalendars(MAX_CALENDARS_FREE + 1),
497                 isFreeUser: true,
498                 result: true,
499             },
500             // shared and owned personal
501             {
502                 number: 1,
503                 calendars: [...generateOwnedPersonalCalendars(1), ...generateSharedCalendars(MAX_CALENDARS_FREE - 1)],
504                 isFreeUser: true,
505                 result: true,
506             },
507             {
508                 number: 1,
509                 calendars: [...generateOwnedPersonalCalendars(2), ...generateSharedCalendars(MAX_CALENDARS_FREE - 2)],
510                 isFreeUser: true,
511                 result: true,
512             },
513             {
514                 number: 1,
515                 calendars: [...generateOwnedPersonalCalendars(1), ...generateSharedCalendars(MAX_CALENDARS_FREE)],
516                 isFreeUser: true,
517                 result: true,
518             },
519             // subscribed and owned personal
520             {
521                 number: 1,
522                 calendars: [
523                     ...generateOwnedPersonalCalendars(1),
524                     ...generateSubscribedCalendars(MAX_CALENDARS_FREE - 1),
525                 ],
526                 isFreeUser: true,
527                 result: true,
528             },
529             {
530                 number: 1,
531                 calendars: [
532                     ...generateOwnedPersonalCalendars(2),
533                     ...generateSubscribedCalendars(MAX_CALENDARS_FREE - 2),
534                 ],
535                 isFreeUser: true,
536                 result: true,
537             },
538             {
539                 number: 1,
540                 calendars: [...generateOwnedPersonalCalendars(1), ...generateSubscribedCalendars(MAX_CALENDARS_FREE)],
541                 isFreeUser: true,
542                 result: true,
543             },
544             // subscribed and shared
545             {
546                 number: 1,
547                 calendars: [...generateSharedCalendars(1), ...generateSubscribedCalendars(1)],
548                 isFreeUser: true,
549                 result: false,
550             },
551             {
552                 number: 1,
553                 calendars: [...generateSharedCalendars(1), ...generateSubscribedCalendars(MAX_CALENDARS_FREE - 2)],
554                 isFreeUser: true,
555                 result: false,
556             },
557             {
558                 number: 1,
559                 calendars: [...generateSharedCalendars(MAX_CALENDARS_FREE - 2), ...generateSubscribedCalendars(1)],
560                 isFreeUser: true,
561                 result: false,
562             },
563             {
564                 number: 1,
565                 calendars: [...generateSubscribedCalendars(2), ...generateSharedCalendars(MAX_CALENDARS_FREE - 2)],
566                 isFreeUser: true,
567                 result: true,
568             },
569             {
570                 number: 1,
571                 calendars: [...generateSharedCalendars(1), ...generateSubscribedCalendars(MAX_CALENDARS_FREE)],
572                 isFreeUser: true,
573                 result: true,
574             },
575             // all
576             {
577                 number: 1,
578                 calendars: [
579                     ...generateOwnedPersonalCalendars(1),
580                     ...generateSharedCalendars(1),
581                     ...generateSubscribedCalendars(1),
582                 ],
583                 isFreeUser: true,
584                 result: true,
585             },
586             {
587                 number: 1,
588                 calendars: [
589                     ...generateOwnedPersonalCalendars(1),
590                     ...generateSharedCalendars(2),
591                     ...generateSubscribedCalendars(3),
592                 ],
593                 isFreeUser: true,
594                 result: true,
595             },
596         ].forEach(({ calendars, number, isFreeUser, result }, i) => {
597             it(`is limit reached for case ${i + 1}`, () => {
598                 expect(willUserReachCalendarsLimit(calendars, number, isFreeUser)).toEqual(result);
599             });
600         });
601     });
603     describe('informs whether the calendar limits for a paid user was reach from easy switch', () => {
604         [
605             // owned calendars
606             {
607                 number: 1,
608                 calendars: generateOwnedPersonalCalendars(MAX_CALENDARS_PAID - 2),
609                 isFreeUser: false,
610                 result: false,
611             },
612             {
613                 number: 1,
614                 calendars: generateOwnedPersonalCalendars(MAX_CALENDARS_PAID),
615                 isFreeUser: false,
616                 result: true,
617             },
618             {
619                 number: 1,
620                 calendars: generateOwnedPersonalCalendars(MAX_CALENDARS_PAID + 1),
621                 isFreeUser: false,
622                 result: true,
623             },
624             // shared calendars
625             {
626                 number: 1,
627                 calendars: generateSharedCalendars(MAX_CALENDARS_PAID - 1),
628                 isFreeUser: false,
629                 result: false,
630             },
631             {
632                 number: 1,
633                 calendars: generateSharedCalendars(MAX_CALENDARS_PAID),
634                 isFreeUser: false,
635                 result: true,
636             },
637             {
638                 number: 1,
639                 calendars: generateSharedCalendars(MAX_CALENDARS_PAID + 1),
640                 isFreeUser: false,
641                 result: true,
642             },
643             // subscribed calendars
644             {
645                 number: 1,
646                 calendars: generateSubscribedCalendars(MAX_CALENDARS_PAID - 1),
647                 isFreeUser: false,
648                 result: false,
649             },
650             {
651                 number: 1,
652                 calendars: generateSubscribedCalendars(MAX_CALENDARS_PAID),
653                 isFreeUser: false,
654                 result: true,
655             },
656             {
657                 number: 1,
658                 calendars: generateSubscribedCalendars(MAX_CALENDARS_PAID + 1),
659                 isFreeUser: false,
660                 result: true,
661             },
662             // shared and owned personal
663             {
664                 number: 1,
665                 calendars: [...generateOwnedPersonalCalendars(1), ...generateSharedCalendars(MAX_CALENDARS_PAID - 1)],
666                 isFreeUser: false,
667                 result: true,
668             },
669             {
670                 number: 1,
671                 calendars: [...generateOwnedPersonalCalendars(2), ...generateSharedCalendars(MAX_CALENDARS_PAID - 2)],
672                 isFreeUser: false,
673                 result: true,
674             },
675             {
676                 number: 1,
677                 calendars: [...generateOwnedPersonalCalendars(1), ...generateSharedCalendars(MAX_CALENDARS_PAID)],
678                 isFreeUser: false,
679                 result: true,
680             },
681             // subscribed and owned personal
682             {
683                 calendars: [
684                     ...generateOwnedPersonalCalendars(1),
685                     ...generateSubscribedCalendars(MAX_CALENDARS_PAID - 1),
686                 ],
687                 number: 1,
688                 isFreeUser: false,
689                 result: true,
690             },
691             {
692                 calendars: [
693                     ...generateOwnedPersonalCalendars(2),
694                     ...generateSubscribedCalendars(MAX_CALENDARS_PAID - 2),
695                 ],
696                 number: 1,
697                 isFreeUser: false,
698                 result: true,
699             },
700             {
701                 number: 1,
702                 calendars: [...generateOwnedPersonalCalendars(1), ...generateSubscribedCalendars(MAX_CALENDARS_PAID)],
703                 isFreeUser: false,
704                 result: true,
705             },
706             // subscribed and shared
707             {
708                 number: 1,
709                 calendars: [...generateSharedCalendars(1), ...generateSubscribedCalendars(MAX_CALENDARS_PAID - 3)],
710                 isFreeUser: false,
711                 result: false,
712             },
713             {
714                 number: 1,
715                 calendars: [...generateSharedCalendars(MAX_CALENDARS_PAID - 3), ...generateSubscribedCalendars(1)],
716                 isFreeUser: false,
717                 result: false,
718             },
719             {
720                 number: 1,
721                 calendars: [...generateSharedCalendars(1), ...generateSubscribedCalendars(MAX_CALENDARS_PAID - 2)],
722                 isFreeUser: false,
723                 result: false,
724             },
725             {
726                 number: 1,
727                 calendars: [...generateSharedCalendars(MAX_CALENDARS_PAID - 2), ...generateSubscribedCalendars(1)],
728                 isFreeUser: false,
729                 result: false,
730             },
731             {
732                 number: 1,
733                 calendars: [...generateSubscribedCalendars(2), ...generateSharedCalendars(MAX_CALENDARS_PAID - 2)],
734                 isFreeUser: false,
735                 result: true,
736             },
737             {
738                 number: 1,
739                 calendars: [...generateSharedCalendars(1), ...generateSubscribedCalendars(MAX_CALENDARS_PAID)],
740                 isFreeUser: false,
741                 result: true,
742             },
743             // all
744             {
745                 calendars: [
746                     ...generateOwnedPersonalCalendars(MAX_CALENDARS_PAID - 6),
747                     ...generateSharedCalendars(2),
748                     ...generateSubscribedCalendars(2),
749                 ],
750                 number: 1,
751                 isFreeUser: false,
752                 result: false,
753             },
754             {
755                 calendars: [
756                     ...generateOwnedPersonalCalendars(MAX_CALENDARS_PAID - 5),
757                     ...generateSharedCalendars(2),
758                     ...generateSubscribedCalendars(3),
759                 ],
760                 number: 1,
761                 isFreeUser: false,
762                 result: true,
763             },
764             {
765                 number: 1,
766                 calendars: [...generateSharedCalendars(MAX_CALENDARS_PAID - 3), ...generateSubscribedCalendars(2)],
767                 isFreeUser: false,
768                 result: false,
769             },
770         ].forEach(({ calendars, number, isFreeUser, result }, i) => {
771             it(`is limit reached for case ${i + 1}`, () => {
772                 expect(willUserReachCalendarsLimit(calendars, number, isFreeUser)).toEqual(result);
773             });
774         });
775     });