1 import { NOTIFICATION_TYPE_API, NOTIFICATION_UNITS, NOTIFICATION_WHEN } from '@proton/shared/lib/calendar/constants';
2 import type { EventModel } from '@proton/shared/lib/interfaces/calendar';
4 import { modelToValarmComponents } from './modelToProperties';
6 describe('modelToValarmComponent', () => {
7 describe('part day', () => {
8 it('should transform to valarm components', () => {
11 partDayNotifications: [
14 type: NOTIFICATION_TYPE_API.EMAIL,
15 unit: NOTIFICATION_UNITS.HOUR,
16 when: NOTIFICATION_WHEN.AFTER,
20 type: NOTIFICATION_TYPE_API.DEVICE,
21 unit: NOTIFICATION_UNITS.MINUTE,
22 when: NOTIFICATION_WHEN.BEFORE,
26 type: NOTIFICATION_TYPE_API.DEVICE,
27 unit: NOTIFICATION_UNITS.MINUTE,
28 when: NOTIFICATION_WHEN.BEFORE,
32 expect(modelToValarmComponents(model)).toEqual(
33 expect.arrayContaining([
86 it('should remove duplicate notifications (part day)', () => {
89 partDayNotifications: [
92 type: NOTIFICATION_TYPE_API.EMAIL,
93 unit: NOTIFICATION_UNITS.HOUR,
94 when: NOTIFICATION_WHEN.AFTER,
98 type: NOTIFICATION_TYPE_API.DEVICE,
99 unit: NOTIFICATION_UNITS.HOUR,
100 when: NOTIFICATION_WHEN.BEFORE,
104 type: NOTIFICATION_TYPE_API.DEVICE,
105 unit: NOTIFICATION_UNITS.MINUTE,
106 when: NOTIFICATION_WHEN.BEFORE,
110 type: NOTIFICATION_TYPE_API.DEVICE,
111 unit: NOTIFICATION_UNITS.MINUTE,
112 when: NOTIFICATION_WHEN.BEFORE,
116 type: NOTIFICATION_TYPE_API.DEVICE,
117 unit: NOTIFICATION_UNITS.MINUTE,
118 when: NOTIFICATION_WHEN.BEFORE,
122 expect(modelToValarmComponents(model)).toEqual([
175 describe('all day', () => {
176 it('should transform to valarm components', () => {
179 fullDayNotifications: [
182 type: NOTIFICATION_TYPE_API.EMAIL,
183 unit: NOTIFICATION_UNITS.DAY,
184 when: NOTIFICATION_WHEN.AFTER,
186 at: new Date(2000, 0, 1, 10, 1),
190 type: NOTIFICATION_TYPE_API.DEVICE,
191 unit: NOTIFICATION_UNITS.DAY,
192 when: NOTIFICATION_WHEN.BEFORE,
194 at: new Date(2000, 0, 1, 10, 1),
198 type: NOTIFICATION_TYPE_API.DEVICE,
199 unit: NOTIFICATION_UNITS.DAY,
200 when: NOTIFICATION_WHEN.BEFORE,
202 at: new Date(2000, 0, 1, 10, 1),
206 expect(modelToValarmComponents(model)).toEqual([
258 it('should remove duplicate notifications', () => {
261 fullDayNotifications: [
264 type: NOTIFICATION_TYPE_API.EMAIL,
265 unit: NOTIFICATION_UNITS.DAY,
266 when: NOTIFICATION_WHEN.AFTER,
268 at: new Date(2000, 0, 1, 10, 1),
272 type: NOTIFICATION_TYPE_API.EMAIL,
273 unit: NOTIFICATION_UNITS.DAY,
274 when: NOTIFICATION_WHEN.AFTER,
276 at: new Date(2000, 0, 1, 10, 1),
280 type: NOTIFICATION_TYPE_API.DEVICE,
281 unit: NOTIFICATION_UNITS.DAY,
282 when: NOTIFICATION_WHEN.AFTER,
284 at: new Date(2000, 0, 1, 10, 1),
288 type: NOTIFICATION_TYPE_API.DEVICE,
289 unit: NOTIFICATION_UNITS.DAY,
290 when: NOTIFICATION_WHEN.AFTER,
292 at: new Date(2000, 0, 1, 10, 1),
296 type: NOTIFICATION_TYPE_API.DEVICE,
297 unit: NOTIFICATION_UNITS.DAY,
298 when: NOTIFICATION_WHEN.BEFORE,
300 at: new Date(2000, 0, 1, 10, 1),
304 type: NOTIFICATION_TYPE_API.DEVICE,
305 unit: NOTIFICATION_UNITS.DAY,
306 when: NOTIFICATION_WHEN.BEFORE,
308 at: new Date(2000, 0, 1, 10, 1),
312 type: NOTIFICATION_TYPE_API.DEVICE,
313 unit: NOTIFICATION_UNITS.DAY,
314 when: NOTIFICATION_WHEN.BEFORE,
316 at: new Date(2000, 0, 1, 10, 1),
320 type: NOTIFICATION_TYPE_API.DEVICE,
321 unit: NOTIFICATION_UNITS.WEEK,
322 when: NOTIFICATION_WHEN.BEFORE,
324 at: new Date(2000, 0, 1, 10, 1),
328 expect(modelToValarmComponents(model)).toEqual(
329 expect.arrayContaining([