fix failing tests for buildMailToUrl

This commit is contained in:
Seyi Adebajo 2018-09-26 22:20:23 -07:00
parent 10e8fdec8a
commit 4e50b07d3e

View File

@ -4,7 +4,7 @@ const bcc = 'nowhere-bcc@example.com';
const body = 'Message'; const body = 'Message';
const subject = 'Email'; const subject = 'Email';
const base = 'mailto:'; const base = 'mailto:';
const mailToEmail = `${base}${emailAddress}`; const mailToEmail = `${base}${encodeURIComponent(emailAddress)}`;
const emailMailToAsserts = [ const emailMailToAsserts = [
{ {
expected: base, expected: base,
@ -28,24 +28,28 @@ const emailMailToAsserts = [
assertMsg: 'it should return a mailto: string with an email when an object with only the `to` field is passed' assertMsg: 'it should return a mailto: string with an email when an object with only the `to` field is passed'
}, },
{ {
expected: `${mailToEmail}?cc=${cc}`, expected: `${mailToEmail}?cc=${encodeURIComponent(cc)}`,
args: { to: emailAddress, cc }, args: { to: emailAddress, cc },
assertMsg: 'it should return a mailto: string with an email and a cc query when to and cc are passed in' assertMsg: 'it should return a mailto: string with an email and a cc query when to and cc are passed in'
}, },
{ {
expected: `${mailToEmail}?cc=${cc}&subject=${subject}`, expected: `${mailToEmail}?cc=${encodeURIComponent(cc)}&subject=${encodeURIComponent(subject)}`,
args: { to: emailAddress, cc, subject }, args: { to: emailAddress, cc, subject },
assertMsg: assertMsg:
'it should return a mailto: string with an email, subject, and a cc query when to, subject, and cc are passed in' 'it should return a mailto: string with an email, subject, and a cc query when to, subject, and cc are passed in'
}, },
{ {
expected: `${mailToEmail}?cc=${cc}&subject=${subject}&bcc=${bcc}`, expected: `${mailToEmail}?cc=${encodeURIComponent(cc)}&subject=${encodeURIComponent(
subject
)}&bcc=${encodeURIComponent(bcc)}`,
args: { to: emailAddress, cc, subject, bcc }, args: { to: emailAddress, cc, subject, bcc },
assertMsg: assertMsg:
'it should return a mailto: string with an email, subject, bcc, and a cc query when to, subject, bcc, and cc are passed in' 'it should return a mailto: string with an email, subject, bcc, and a cc query when to, subject, bcc, and cc are passed in'
}, },
{ {
expected: `${mailToEmail}?cc=${cc}&subject=${subject}&bcc=${bcc}&body=${body}`, expected: `${mailToEmail}?cc=${encodeURIComponent(cc)}&subject=${encodeURIComponent(
subject
)}&bcc=${encodeURIComponent(bcc)}&body=${encodeURIComponent(body)}`,
args: { to: emailAddress, cc, subject, bcc, body }, args: { to: emailAddress, cc, subject, bcc, body },
assertMsg: assertMsg:
'it should return a mailto: string with an email, subject, bcc, body, and a cc query when to, subject, bcc, body, and cc are passed in' 'it should return a mailto: string with an email, subject, bcc, body, and a cc query when to, subject, bcc, body, and cc are passed in'