-
Notifications
You must be signed in to change notification settings - Fork 155
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CUTYPE and X-NUM-GUESTS support (#244)
* Add participation type for CUtype fields + support for x-num-guests x-num-guests is a string for now to prevent its unnecessary inclusion * Add xnum guests + cutype to schema * Add additional fields to formatted attendee + format so that semicolon always ends first part and mailto always ends * restrict sequence and make x-num-guests a number * RSVP is not a required field * typeof not needed for undefined check --------- Co-authored-by: Adrian Curtin <[email protected]>
- Loading branch information
1 parent
4285364
commit e4784fd
Showing
6 changed files
with
78 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,27 @@ | ||
export default function setContact({ name, email, rsvp, dir, partstat, role }) { | ||
let formattedAttendee = '' | ||
formattedAttendee += rsvp ? 'RSVP=TRUE;' : 'RSVP=FALSE;' | ||
formattedAttendee += role ? `ROLE=${role};` : '' | ||
formattedAttendee += partstat ? `PARTSTAT=${partstat};` : '' | ||
formattedAttendee += dir ? `DIR=${dir};` : '' | ||
formattedAttendee += 'CN=' | ||
formattedAttendee += name || 'Unnamed attendee' | ||
formattedAttendee += email ? `:mailto:${email}` : '' | ||
export default function setContact({ name, email, rsvp, dir, partstat, role, cutype, xNumGuests }) { | ||
let formattedParts = []; | ||
|
||
if(rsvp !== undefined){ | ||
formattedParts.push(rsvp ? 'RSVP=TRUE' : 'RSVP=FALSE'); | ||
} | ||
if(cutype){ | ||
formattedParts.push("CUTYPE=".concat(cutype)); | ||
} | ||
if(xNumGuests !== undefined){ | ||
formattedParts.push(`X-NUM-GUESTS=${xNumGuests}`); | ||
} | ||
if(role){ | ||
formattedParts.push("ROLE=".concat(role)); | ||
} | ||
if(partstat){ | ||
formattedParts.push("PARTSTAT=".concat(partstat)); | ||
} | ||
if(dir){ | ||
formattedParts.push("DIR=".concat(dir)); | ||
} | ||
formattedParts.push('CN='.concat((name || 'Unnamed attendee'))); | ||
|
||
var formattedAttendee = formattedParts.join(';').concat(email ? ":mailto:".concat(email) : ''); | ||
|
||
return formattedAttendee | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -175,7 +175,7 @@ describe('pipeline.formatEvent', () => { | |
{name: 'Brittany Seaton', email: '[email protected]', rsvp: true } | ||
]}) | ||
const formattedEvent = formatEvent(event) | ||
expect(formattedEvent).to.contain('ATTENDEE;RSVP=FALSE;CN=Adam Gibbons:mailto:[email protected]') | ||
expect(formattedEvent).to.contain('ATTENDEE;CN=Adam Gibbons:mailto:[email protected]') | ||
expect(formattedEvent).to.contain('ATTENDEE;RSVP=TRUE;CN=Brittany Seaton:mailto:[email protected]') | ||
}) | ||
it('writes a busystatus', () => { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,20 +4,24 @@ import { setContact } from '../../src/utils' | |
describe('utils.setContact', () => { | ||
it('set a contact with role', () => { | ||
const contact = { name: 'm-vinc', email: '[email protected]' } | ||
expect(setContact(contact)) | ||
.to.equal(`CN=m-vinc:mailto:[email protected]`) | ||
|
||
const contactChair = Object.assign({role: 'CHAIR'}, contact) | ||
const contactRequired = Object.assign({role: 'REQ-PARTICIPANT' }, contact) | ||
const contactOptional = Object.assign({role: 'OPT-PARTICIPANT' }, contact) | ||
const contactNon = Object.assign({role: 'NON-PARTICIPANT' }, contact) | ||
expect(setContact(contactChair)) | ||
.to.equal(`RSVP=FALSE;ROLE=CHAIR;CN=m-vinc:mailto:[email protected]`) | ||
.to.equal(`ROLE=CHAIR;CN=m-vinc:mailto:[email protected]`) | ||
|
||
const contactRequired = Object.assign({role: 'REQ-PARTICIPANT', rsvp: true }, contact) | ||
expect(setContact(contactRequired)) | ||
.to.equal(`RSVP=FALSE;ROLE=REQ-PARTICIPANT;CN=m-vinc:mailto:[email protected]`) | ||
.to.equal(`RSVP=TRUE;ROLE=REQ-PARTICIPANT;CN=m-vinc:mailto:[email protected]`) | ||
|
||
const contactOptional = Object.assign({role: 'OPT-PARTICIPANT', rsvp: false }, contact) | ||
expect(setContact(contactOptional)) | ||
.to.equal(`RSVP=FALSE;ROLE=OPT-PARTICIPANT;CN=m-vinc:mailto:[email protected]`) | ||
|
||
const contactNon = Object.assign({role: 'NON-PARTICIPANT' }, contact) | ||
expect(setContact(contactNon)) | ||
.to.equal(`RSVP=FALSE;ROLE=NON-PARTICIPANT;CN=m-vinc:mailto:[email protected]`) | ||
expect(setContact(contact)) | ||
.to.equal(`RSVP=FALSE;CN=m-vinc:mailto:[email protected]`) | ||
.to.equal(`ROLE=NON-PARTICIPANT;CN=m-vinc:mailto:[email protected]`) | ||
}) | ||
it('set a contact with partstat', () => { | ||
const contact = { name: 'm-vinc', email: '[email protected]' } | ||
|
@@ -28,21 +32,21 @@ describe('utils.setContact', () => { | |
const contactTentative = Object.assign({contact, partstat: 'TENTATIVE'}, contact) | ||
|
||
expect(setContact(contactUndefined)) | ||
.to.equal('RSVP=FALSE;CN=m-vinc:mailto:[email protected]') | ||
.to.equal('CN=m-vinc:mailto:[email protected]') | ||
|
||
expect(setContact(contactNeedsAction)) | ||
.to.equal('RSVP=FALSE;PARTSTAT=NEEDS-ACTION;CN=m-vinc:mailto:[email protected]') | ||
.to.equal('PARTSTAT=NEEDS-ACTION;CN=m-vinc:mailto:[email protected]') | ||
|
||
expect(setContact(contactDeclined)) | ||
.to.equal('RSVP=FALSE;PARTSTAT=DECLINED;CN=m-vinc:mailto:[email protected]') | ||
.to.equal('PARTSTAT=DECLINED;CN=m-vinc:mailto:[email protected]') | ||
|
||
expect(setContact(contactTentative)) | ||
.to.equal('RSVP=FALSE;PARTSTAT=TENTATIVE;CN=m-vinc:mailto:[email protected]') | ||
.to.equal('PARTSTAT=TENTATIVE;CN=m-vinc:mailto:[email protected]') | ||
|
||
expect(setContact(contactAccepted)) | ||
.to.equal('RSVP=FALSE;PARTSTAT=ACCEPTED;CN=m-vinc:mailto:[email protected]') | ||
.to.equal('PARTSTAT=ACCEPTED;CN=m-vinc:mailto:[email protected]') | ||
}) | ||
it('sets a contact and defaults RSVP to false', () => { | ||
it('sets a contact and only sets RSVP if specified', () => { | ||
const contact1 = { | ||
name: 'Adam Gibbons', | ||
email: '[email protected]' | ||
|
@@ -56,9 +60,17 @@ describe('utils.setContact', () => { | |
} | ||
|
||
expect(setContact(contact1)) | ||
.to.equal('RSVP=FALSE;CN=Adam Gibbons:mailto:[email protected]') | ||
.to.equal('CN=Adam Gibbons:mailto:[email protected]') | ||
|
||
expect(setContact(contact2)) | ||
.to.equal('RSVP=TRUE;DIR=https://example.com/contacts/adam;CN=Adam Gibbons:mailto:[email protected]') | ||
}) | ||
it('set a contact with cutype and guests', () => { | ||
const contact = { name: 'm-vinc', email: '[email protected]' } | ||
const contactCuGuests = Object.assign({ cutype: 'INDIVIDUAL', xNumGuests: 0 }, contact) | ||
const contactString = setContact(contactCuGuests) | ||
|
||
expect(contactString).to.contain('CUTYPE=INDIVIDUAL') | ||
expect(contactString).to.contain('X-NUM-GUESTS=0') | ||
}) | ||
}) |