From 3d0090f7ffc0f3c11b536018b10a2f099c7a9abc Mon Sep 17 00:00:00 2001 From: Elmer Thomas Date: Fri, 25 Aug 2017 14:37:17 -0700 Subject: [PATCH] setSubstitutions and reverseMergeSubstitutions should accept null --- packages/helpers/classes/personalization.js | 6 +++--- packages/helpers/classes/personalization.spec.js | 14 +++++++------- packages/mail/USE_CASES.md | 4 ++-- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/packages/helpers/classes/personalization.js b/packages/helpers/classes/personalization.js index d0b92d70b..5b0f6e490 100644 --- a/packages/helpers/classes/personalization.js +++ b/packages/helpers/classes/personalization.js @@ -221,7 +221,7 @@ class Personalization { if (typeof substitutions === 'undefined') { return; } - if (typeof substitutions !== 'object' || substitutions === null) { + if (typeof substitutions !== 'object') { throw new Error('Object expected for `substitutions`'); } this.substitutions = substitutions; @@ -247,8 +247,8 @@ class Personalization { if (typeof substitutions === 'undefined') { return; } - if (typeof substitutions !== 'object' || substitutions === null) { - throw new Error('Object expected for `substitutions`'); + if (typeof substitutions !== 'object') { + throw new Error('Object expected for `substitutions` in reverseMergeSubstitutions'); } this.substitutions = Object.assign({}, substitutions, this.substitutions); } diff --git a/packages/helpers/classes/personalization.spec.js b/packages/helpers/classes/personalization.spec.js index ca1bda218..c3450bab5 100644 --- a/packages/helpers/classes/personalization.spec.js +++ b/packages/helpers/classes/personalization.spec.js @@ -406,11 +406,11 @@ describe('Personalization', function() { }); it('should throw an error for invalid input', function() { expect(function() { - p.setSubstitutions('Invalid'); - }).to.throw(Error); - expect(function() { - p.setSubstitutions(null); + p.setSubstitutions(3); }).to.throw(Error); + //expect(function() { + //p.setSubstitutions(null); + //}).to.throw(Error); }); it('should accept no input', function() { expect(function() { @@ -480,9 +480,9 @@ describe('Personalization', function() { expect(function() { p.reverseMergeSubstitutions(3); }).to.throw(Error); - expect(function() { - p.reverseMergeSubstitutions(null); - }).to.throw(Error); + //expect(function() { + //p.reverseMergeSubstitutions(null); + //}).to.throw(Error); }); it('should accept no input', function() { expect(function() { diff --git a/packages/mail/USE_CASES.md b/packages/mail/USE_CASES.md index 596dd3997..3542125b1 100644 --- a/packages/mail/USE_CASES.md +++ b/packages/mail/USE_CASES.md @@ -224,7 +224,7 @@ I hope you are having a great day in -city- :) ```js const sgMail = require('@sendgrid/mail'); sgMail.setApiKey(process.env.SENDGRID_API_KEY); -sgMail.setSubstitutionWrappers('-', '-'); // Configure the substitution tag wrappers globally +sgMail.setSubstitutionWrappers('{{', '}}'); // Configure the substitution tag wrappers globally const msg = { to: 'recipient@example.org', from: 'sender@example.org', @@ -245,7 +245,7 @@ Alternatively, you may specify the substitution wrappers via the msg object as w ```js const msg = { ... - substitutionWrappers: ['-', '-'], + substitutionWrappers: ['{{', '}}'], ... }; ```