1 import { triggerToModel
} from '@proton/shared/lib/calendar/alarms/notificationModel';
2 import { NOTIFICATION_TYPE_API
, NOTIFICATION_UNITS
, NOTIFICATION_WHEN
} from '@proton/shared/lib/calendar/constants';
3 import { fromTriggerString
} from '@proton/shared/lib/calendar/vcal';
5 const { DEVICE
} = NOTIFICATION_TYPE_API
;
6 const { WEEK
, DAY
, HOUR
, MINUTE
} = NOTIFICATION_UNITS
;
7 const { AFTER
, BEFORE
} = NOTIFICATION_WHEN
;
9 describe('properties to model positive trigger', () => {
10 test('part day 0', () => {
15 trigger
: fromTriggerString('PT0S'),
26 test('part day trigger 1 minute', () => {
31 trigger
: fromTriggerString('PT1M'),
42 test('all day trigger at 10:01 on the same day', () => {
47 trigger
: fromTriggerString('PT10H1M'),
55 at
: new Date(2000, 0, 1, 10, 1),
59 test('all day trigger at 10:01 a day after', () => {
64 trigger
: fromTriggerString('PT1D10H1M'),
72 at
: new Date(2000, 0, 1, 10, 1),
76 test('all day trigger at 10:01 a week after', () => {
81 trigger
: fromTriggerString('PT1W10H1M'),
89 at
: new Date(2000, 0, 1, 10, 1),
93 test('all day trigger at 10:01 a week and two days after', () => {
98 trigger
: fromTriggerString('PT1W2D10H1M'),
106 at
: new Date(2000, 0, 1, 10, 1),
111 describe('properties to model negative trigger', () => {
112 test('part day notification 15 hours before', () => {
117 trigger
: fromTriggerString('-PT15H'),
128 test('part day notification 1 day before', () => {
133 trigger
: fromTriggerString('-PT1D'),
144 test('part day notification 1 day and 15 hours before', () => {
149 trigger
: fromTriggerString('-PT1D15H'),
160 test('part day notification 60 minutes before', () => {
165 trigger
: fromTriggerString('-PT60M'),
176 test('part day notification with two components 1 week minutes before', () => {
181 trigger
: fromTriggerString('-PT24H6D'),
192 test('all day notification 1 day before at 00:00', () => {
197 trigger
: fromTriggerString('-PT1D'),
205 at
: new Date(2000, 0, 1, 0, 0),
209 test('all day notification 1 day before at 13:50', () => {
214 trigger
: fromTriggerString('-PT10H10M'),
222 at
: new Date(2000, 0, 1, 13, 50),
226 test('all day notification 1 week before at 00:00', () => {
231 trigger
: fromTriggerString('-PT1W'),
239 at
: new Date(2000, 0, 1, 0, 0),
243 test('all day notification 1 week and 6 days before', () => {
248 trigger
: fromTriggerString('-PT1W6D'),
256 at
: new Date(2000, 0, 1, 0, 0),
260 test('all day notification 1 week before at 13:50', () => {
265 trigger
: fromTriggerString('-PT6D10H10M'),
273 at
: new Date(2000, 0, 1, 13, 50),
277 test('all day notification 2 weeks before at 13:50', () => {
282 trigger
: fromTriggerString('-PT1W6D10H10M'),
290 at
: new Date(2000, 0, 1, 13, 50),
294 test('all day notification 1 week and 6 days before at 13:50', () => {
299 trigger
: fromTriggerString('-PT1W5D10H10M'),
307 at
: new Date(2000, 0, 1, 13, 50),
311 test('all day notification 8 days before at 15:35 in two ways', () => {
316 trigger
: fromTriggerString('-P1WT8H25M'),
324 at
: new Date(2000, 0, 1, 15, 35),
331 trigger
: fromTriggerString('-P7DT8H25M'),
339 at
: new Date(2000, 0, 1, 15, 35),