Remove client-side isLoggedIn value
[ProtonMail-WebClient.git] / packages / shared / test / calendar / calendar.spec.ts
blobba6d95c386489c17b71d9e747954082a8661aded
1 import { sortCalendars } from '@proton/shared/lib/calendar/calendar';
2 import { CALENDAR_TYPE } from '@proton/shared/lib/calendar/constants';
3 import type { VisualCalendar } from '@proton/shared/lib/interfaces/calendar';
5 describe('sortCalendars', () => {
6     const holidaysCalendar = {
7         Type: CALENDAR_TYPE.HOLIDAYS,
8         Priority: 1,
9         Members: [{ Email: 'teestpm1@pm.me', Priority: 1 }],
10     } as VisualCalendar;
11     const subscribedCalendar = {
12         Type: CALENDAR_TYPE.SUBSCRIPTION,
13         Owner: { Email: 'otherpmowner@pm.me' },
14         Priority: 1,
15         Members: [{ Email: 'teestpm1@pm.me', Priority: 1 }],
16     } as VisualCalendar;
17     const sharedCalendar = {
18         Type: CALENDAR_TYPE.PERSONAL,
19         Owner: { Email: 'otherpmowner@pm.me' },
20         Priority: 1,
21         Members: [{ Email: 'teestpm1@pm.me', Priority: 1 }],
22     } as VisualCalendar;
23     const sharedCalendarB = {
24         Type: CALENDAR_TYPE.PERSONAL,
25         Owner: { Email: 'otherpmowner@pm.me' },
26         Priority: 2,
27         Members: [{ Email: 'teestpm1@pm.me', Priority: 2 }],
28     } as VisualCalendar;
29     const ownedCalendar = {
30         Type: CALENDAR_TYPE.PERSONAL,
31         Owner: { Email: 'teestpm1@pm.me' },
32         Priority: 1,
33         Members: [{ Email: 'teestpm1@pm.me', Priority: 1 }],
34     } as VisualCalendar;
35     const ownedCalendarB = {
36         Type: CALENDAR_TYPE.PERSONAL,
37         Owner: { Email: 'teestpm1@pm.me' },
38         Priority: 2,
39         Members: [{ Email: 'teestpm1@pm.me', Priority: 2 }],
40     } as VisualCalendar;
42     it('should return calendars sorted by weight', () => {
43         expect(sortCalendars([holidaysCalendar, subscribedCalendar, sharedCalendar, ownedCalendar])).toEqual([
44             ownedCalendar,
45             subscribedCalendar,
46             holidaysCalendar,
47             sharedCalendar,
48         ]);
49     });
51     describe('when some calendars have same weight', () => {
52         it('should sort them by priority', () => {
53             expect(
54                 sortCalendars([
55                     holidaysCalendar,
56                     sharedCalendarB,
57                     subscribedCalendar,
58                     ownedCalendarB,
59                     sharedCalendar,
60                     ownedCalendar,
61                 ])
62             ).toEqual([
63                 ownedCalendar,
64                 ownedCalendarB,
65                 subscribedCalendar,
66                 holidaysCalendar,
67                 sharedCalendar,
68                 sharedCalendarB,
69             ]);
70         });
71     });
72 });