diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
commit | 6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch) | |
tree | a68f146d7fa01f0134297619fbe7e33db084e0aa /comm/calendar/test/unit/test_bug1199942.js | |
parent | Initial commit. (diff) | |
download | thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.tar.xz thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.zip |
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'comm/calendar/test/unit/test_bug1199942.js')
-rw-r--r-- | comm/calendar/test/unit/test_bug1199942.js | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/comm/calendar/test/unit/test_bug1199942.js b/comm/calendar/test/unit/test_bug1199942.js new file mode 100644 index 0000000000..7d78cb1244 --- /dev/null +++ b/comm/calendar/test/unit/test_bug1199942.js @@ -0,0 +1,81 @@ +/* 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 { cal } = ChromeUtils.import("resource:///modules/calendar/calUtils.jsm"); +var { XPCOMUtils } = ChromeUtils.importESModule("resource://gre/modules/XPCOMUtils.sys.mjs"); + +XPCOMUtils.defineLazyModuleGetters(this, { + CalAttendee: "resource:///modules/CalAttendee.jsm", + CalEvent: "resource:///modules/CalEvent.jsm", +}); + +function run_test() { + // Test the graceful handling of attendee ids for bug 1199942 + createAttendee_test(); + serializeEvent_test(); +} + +function createAttendee_test() { + let data = [ + { input: "mailto:user1@example.net", expected: "mailto:user1@example.net" }, + { input: "MAILTO:user2@example.net", expected: "mailto:user2@example.net" }, + { input: "user3@example.net", expected: "mailto:user3@example.net" }, + { input: "urn:uuid:user4", expected: "urn:uuid:user4" }, + ]; + let event = new CalEvent(); + for (let test of data) { + let attendee = new CalAttendee(); + attendee.id = test.input; + event.addAttendee(attendee); + let readAttendee = event.getAttendeeById(cal.email.prependMailTo(test.input)); + equal(readAttendee.id, test.expected); + } +} + +function serializeEvent_test() { + let ics = + "BEGIN:VCALENDAR\n" + + "PRODID:-//Mozilla.org/NONSGML Mozilla Calendar V1.1//EN\n" + + "VERSION:2.0\n" + + "BEGIN:VEVENT\n" + + "CREATED:20150801T213509Z\n" + + "LAST-MODIFIED:20150830T164104Z\n" + + "DTSTAMP:20150830T164104Z\n" + + "UID:a84c74d1-cfc6-4ddf-9d60-9e4afd8238cf\n" + + "SUMMARY:New Event\n" + + "ORGANIZER;RSVP=TRUE;CN=Tester1;PARTSTAT=ACCEPTED;ROLE=CHAIR:mailto:user1@example.net\n" + + "ATTENDEE;RSVP=TRUE;PARTSTAT=NEEDS-ACTION;ROLE=REQ-PARTICIPANT:MAILTO:user2@example.net\n" + + "ATTENDEE;RSVP=TRUE;PARTSTAT=NEEDS-ACTION;ROLE=REQ-PARTICIPANT:mailto:user3@example.net\n" + + "ATTENDEE;RSVP=TRUE;PARTSTAT=NEEDS-ACTION;ROLE=REQ-PARTICIPANT:user4@example.net\n" + + "ATTENDEE;RSVP=TRUE;PARTSTAT=NEEDS-ACTION;ROLE=REQ-PARTICIPANT:urn:uuid:user5\n" + + "DTSTART:20150729T103000Z\n" + + "DTEND:20150729T113000Z\n" + + "TRANSP:OPAQUE\n" + + "END:VEVENT\n" + + "END:VCALENDAR\n"; + + let expectedIds = [ + "mailto:user2@example.net", + "mailto:user3@example.net", + "mailto:user4@example.net", + "urn:uuid:user5", + ]; + let event = createEventFromIcalString(ics); + let attendees = event.getAttendees(); + + // check whether all attendees get returned with expected id + for (let attendee of attendees) { + ok(expectedIds.includes(attendee.id)); + } + + // serialize the event again and check whether the attendees still are in shape + let serializer = Cc["@mozilla.org/calendar/ics-serializer;1"].createInstance( + Ci.calIIcsSerializer + ); + serializer.addItems([event]); + let serialized = ics_unfoldline(serializer.serializeToString()); + for (let id of expectedIds) { + ok(serialized.search(id) != -1); + } +} |