fix failing tests for buildMailToUrl
@@ -4,7 +4,7 @@ const bcc = 'nowhere-bcc@example.com';
const body = 'Message';
const subject = 'Email';
const base = 'mailto:';
-const mailToEmail = `${base}${emailAddress}`;
+const mailToEmail = `${base}${encodeURIComponent(emailAddress)}`;
const emailMailToAsserts = [
{
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'
},
{
- expected: `${mailToEmail}?cc=${cc}`,
+ expected: `${mailToEmail}?cc=${encodeURIComponent(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'
},
{
- expected: `${mailToEmail}?cc=${cc}&subject=${subject}`,
+ expected: `${mailToEmail}?cc=${encodeURIComponent(cc)}&subject=${encodeURIComponent(subject)}`,
args: { to: emailAddress, cc, subject },
assertMsg:
'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 },
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'
},
{
- 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 },
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'
