diff options
Diffstat (limited to 'comm/calendar/test/unit/test_bug485571.js')
-rw-r--r-- | comm/calendar/test/unit/test_bug485571.js | 99 |
1 files changed, 99 insertions, 0 deletions
diff --git a/comm/calendar/test/unit/test_bug485571.js b/comm/calendar/test/unit/test_bug485571.js new file mode 100644 index 0000000000..855109b7e8 --- /dev/null +++ b/comm/calendar/test/unit/test_bug485571.js @@ -0,0 +1,99 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +var { XPCOMUtils } = ChromeUtils.importESModule("resource://gre/modules/XPCOMUtils.sys.mjs"); + +XPCOMUtils.defineLazyModuleGetters(this, { + CalAlarm: "resource:///modules/CalAlarm.jsm", +}); + +function run_test() { + // Check that the RELATED property is correctly set + // after parsing the given VALARM component + + // trigger set 15 minutes prior to the start of the event + check_relative( + "BEGIN:VALARM\n" + + "ACTION:DISPLAY\n" + + "TRIGGER:-PT15M\n" + + "DESCRIPTION:TEST\n" + + "END:VALARM", + Ci.calIAlarm.ALARM_RELATED_START + ); + + // trigger set 15 minutes prior to the start of the event + check_relative( + "BEGIN:VALARM\n" + + "ACTION:DISPLAY\n" + + "TRIGGER;VALUE=DURATION:-PT15M\n" + + "DESCRIPTION:TEST\n" + + "END:VALARM", + Ci.calIAlarm.ALARM_RELATED_START + ); + + // trigger set 15 minutes prior to the start of the event + check_relative( + "BEGIN:VALARM\n" + + "ACTION:DISPLAY\n" + + "TRIGGER;RELATED=START:-PT15M\n" + + "DESCRIPTION:TEST\n" + + "END:VALARM", + Ci.calIAlarm.ALARM_RELATED_START + ); + + // trigger set 15 minutes prior to the start of the event + check_relative( + "BEGIN:VALARM\n" + + "ACTION:DISPLAY\n" + + "TRIGGER;VALUE=DURATION;RELATED=START:-PT15M\n" + + "DESCRIPTION:TEST\n" + + "END:VALARM", + Ci.calIAlarm.ALARM_RELATED_START + ); + + // trigger set 5 minutes after the end of an event + check_relative( + "BEGIN:VALARM\n" + + "ACTION:DISPLAY\n" + + "TRIGGER;RELATED=END:PT5M\n" + + "DESCRIPTION:TEST\n" + + "END:VALARM", + Ci.calIAlarm.ALARM_RELATED_END + ); + + // trigger set 5 minutes after the end of an event + check_relative( + "BEGIN:VALARM\n" + + "ACTION:DISPLAY\n" + + "TRIGGER;VALUE=DURATION;RELATED=END:PT5M\n" + + "DESCRIPTION:TEST\n" + + "END:VALARM", + Ci.calIAlarm.ALARM_RELATED_END + ); + + // trigger set to an absolute date/time + check_absolute( + "BEGIN:VALARM\n" + + "ACTION:DISPLAY\n" + + "TRIGGER;VALUE=DATE-TIME:20090430T080000Z\n" + + "DESCRIPTION:TEST\n" + + "END:VALARM" + ); +} + +function check_relative(aIcalString, aRelated) { + let alarm = new CalAlarm(); + alarm.icalString = aIcalString; + equal(alarm.related, aRelated); + equal(alarm.alarmDate, null); + notEqual(alarm.offset, null); +} + +function check_absolute(aIcalString) { + let alarm = new CalAlarm(); + alarm.icalString = aIcalString; + equal(alarm.related, Ci.calIAlarm.ALARM_RELATED_ABSOLUTE); + ok(alarm.alarmDate != null); + equal(alarm.offset, null); +} |