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,
9 Members: [{ Email: 'teestpm1@pm.me', Priority: 1 }],
11 const subscribedCalendar = {
12 Type: CALENDAR_TYPE.SUBSCRIPTION,
13 Owner: { Email: 'otherpmowner@pm.me' },
15 Members: [{ Email: 'teestpm1@pm.me', Priority: 1 }],
17 const sharedCalendar = {
18 Type: CALENDAR_TYPE.PERSONAL,
19 Owner: { Email: 'otherpmowner@pm.me' },
21 Members: [{ Email: 'teestpm1@pm.me', Priority: 1 }],
23 const sharedCalendarB = {
24 Type: CALENDAR_TYPE.PERSONAL,
25 Owner: { Email: 'otherpmowner@pm.me' },
27 Members: [{ Email: 'teestpm1@pm.me', Priority: 2 }],
29 const ownedCalendar = {
30 Type: CALENDAR_TYPE.PERSONAL,
31 Owner: { Email: 'teestpm1@pm.me' },
33 Members: [{ Email: 'teestpm1@pm.me', Priority: 1 }],
35 const ownedCalendarB = {
36 Type: CALENDAR_TYPE.PERSONAL,
37 Owner: { Email: 'teestpm1@pm.me' },
39 Members: [{ Email: 'teestpm1@pm.me', Priority: 2 }],
42 it('should return calendars sorted by weight', () => {
43 expect(sortCalendars([holidaysCalendar, subscribedCalendar, sharedCalendar, ownedCalendar])).toEqual([
51 describe('when some calendars have same weight', () => {
52 it('should sort them by priority', () => {