-
Notifications
You must be signed in to change notification settings - Fork 780
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #691 from prohabits/master
Added support for dynamicTemplateData
- Loading branch information
Showing
17 changed files
with
1,237 additions
and
437 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,6 @@ | ||
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. | ||
# yarn lockfile v1 | ||
"@sendgrid/helpers@^6.0.0": | ||
version "6.0.0" | ||
resolved "https://registry.yarnpkg.com/@sendgrid/helpers/-/helpers-6.0.0.tgz#b7ae9b927822e6a3a3e44abb2486e68d03e25220" | ||
dependencies: | ||
chalk "^2.0.1" | ||
|
||
|
||
"@types/form-data@*": | ||
version "2.2.0" | ||
|
@@ -30,24 +26,18 @@ ajv@^4.9.1: | |
co "^4.6.0" | ||
json-stable-stringify "^1.0.1" | ||
|
||
ansi-styles@^3.1.0: | ||
version "3.2.0" | ||
resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-3.2.0.tgz#c159b8d5be0f9e5a6f346dab94f16ce022161b88" | ||
dependencies: | ||
color-convert "^1.9.0" | ||
|
||
asn1@~0.2.3: | ||
version "0.2.3" | ||
resolved "https://registry.yarnpkg.com/asn1/-/asn1-0.2.3.tgz#dac8787713c9966849fc8180777ebe9c1ddf3b86" | ||
|
||
[email protected], assert-plus@^1.0.0: | ||
version "1.0.0" | ||
resolved "https://registry.yarnpkg.com/assert-plus/-/assert-plus-1.0.0.tgz#f12e0f3c5d77b0b1cdd9146942e4e96c1e4dd525" | ||
|
||
assert-plus@^0.2.0: | ||
version "0.2.0" | ||
resolved "https://registry.yarnpkg.com/assert-plus/-/assert-plus-0.2.0.tgz#d74e1b87e7affc0db8aadb7021f3fe48101ab234" | ||
|
||
assert-plus@^1.0.0, [email protected]: | ||
version "1.0.0" | ||
resolved "https://registry.yarnpkg.com/assert-plus/-/assert-plus-1.0.0.tgz#f12e0f3c5d77b0b1cdd9146942e4e96c1e4dd525" | ||
|
||
asynckit@^0.4.0: | ||
version "0.4.0" | ||
resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79" | ||
|
@@ -76,28 +66,10 @@ caseless@~0.12.0: | |
version "0.12.0" | ||
resolved "https://registry.yarnpkg.com/caseless/-/caseless-0.12.0.tgz#1b681c21ff84033c826543090689420d187151dc" | ||
|
||
chalk@^2.0.1: | ||
version "2.1.0" | ||
resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.1.0.tgz#ac5becf14fa21b99c6c92ca7a7d7cfd5b17e743e" | ||
dependencies: | ||
ansi-styles "^3.1.0" | ||
escape-string-regexp "^1.0.5" | ||
supports-color "^4.0.0" | ||
|
||
co@^4.6.0: | ||
version "4.6.0" | ||
resolved "https://registry.yarnpkg.com/co/-/co-4.6.0.tgz#6ea6bdf3d853ae54ccb8e47bfa0bf3f9031fb184" | ||
|
||
color-convert@^1.9.0: | ||
version "1.9.0" | ||
resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-1.9.0.tgz#1accf97dd739b983bf994d56fec8f95853641b7a" | ||
dependencies: | ||
color-name "^1.1.1" | ||
|
||
color-name@^1.1.1: | ||
version "1.1.3" | ||
resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.3.tgz#a7d0558bd89c42f795dd42328f740831ca53bc25" | ||
|
||
combined-stream@^1.0.5, combined-stream@~1.0.5: | ||
version "1.0.5" | ||
resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-1.0.5.tgz#938370a57b4a51dea2c77c15d5c5fdf895164009" | ||
|
@@ -126,10 +98,6 @@ ecc-jsbn@~0.1.1: | |
dependencies: | ||
jsbn "~0.1.0" | ||
|
||
escape-string-regexp@^1.0.5: | ||
version "1.0.5" | ||
resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" | ||
|
||
extend@~3.0.0: | ||
version "3.0.1" | ||
resolved "https://registry.yarnpkg.com/extend/-/extend-3.0.1.tgz#a755ea7bc1adfcc5a31ce7e762dbaadc5e636444" | ||
|
@@ -167,10 +135,6 @@ har-validator@~4.2.1: | |
ajv "^4.9.1" | ||
har-schema "^1.0.5" | ||
|
||
has-flag@^2.0.0: | ||
version "2.0.0" | ||
resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-2.0.0.tgz#e8207af1cc7b30d446cc70b734b5e8be18f88d51" | ||
|
||
hawk@~3.1.3: | ||
version "3.1.3" | ||
resolved "https://registry.yarnpkg.com/hawk/-/hawk-3.1.3.tgz#078444bd7c1640b0fe540d2c9b73d59678e8e1c4" | ||
|
@@ -312,12 +276,6 @@ stringstream@~0.0.4: | |
version "0.0.5" | ||
resolved "https://registry.yarnpkg.com/stringstream/-/stringstream-0.0.5.tgz#4e484cd4de5a0bbbee18e46307710a8a81621878" | ||
|
||
supports-color@^4.0.0: | ||
version "4.2.1" | ||
resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-4.2.1.tgz#65a4bb2631e90e02420dba5554c375a4754bb836" | ||
dependencies: | ||
has-flag "^2.0.0" | ||
|
||
tough-cookie@~2.3.0: | ||
version "2.3.2" | ||
resolved "https://registry.yarnpkg.com/tough-cookie/-/tough-cookie-2.3.2.tgz#f081f76e4c85720e6c37a5faced737150d84072a" | ||
|
@@ -343,4 +301,3 @@ [email protected]: | |
resolved "https://registry.yarnpkg.com/verror/-/verror-1.3.6.tgz#cff5df12946d297d2baaefaa2689e25be01c005c" | ||
dependencies: | ||
extsprintf "1.0.2" | ||
|
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 |
---|---|---|
|
@@ -40,4 +40,118 @@ describe('Mail', function() { | |
.equal('<mailto:[email protected]>'); | ||
}); | ||
}); | ||
describe('#689', function() { | ||
|
||
it('should detect dynamic template id', function() { | ||
const mail = new Mail({ | ||
personalizations: [{ | ||
to: '[email protected]', | ||
headers: { | ||
'test-header': 'test', | ||
}, | ||
}], | ||
from: { | ||
email: '[email protected]', | ||
}, | ||
templateId: 'd-df80613cccc6441ea5cd7c95377bc1ef', | ||
subject: 'test', | ||
content: [{ | ||
type: 'text/plain', | ||
value: 'test', | ||
}], | ||
}); | ||
expect(mail.isDynamic).to.equal(true); | ||
}); | ||
it('should detect legacy template id', function() { | ||
const mail = new Mail({ | ||
personalizations: [{ | ||
to: '[email protected]', | ||
headers: { | ||
'test-header': 'test', | ||
}, | ||
}], | ||
from: { | ||
email: '[email protected]', | ||
}, | ||
templateId: 'df80613cccc6441ea5cd7c95377bc1ef', | ||
subject: 'test', | ||
content: [{ | ||
type: 'text/plain', | ||
value: 'test', | ||
}], | ||
}); | ||
expect(mail.isDynamic).to.equal(false); | ||
}); | ||
it('should ignore substitutions if templateId is dynamic', function() { | ||
const mail = new Mail({ | ||
personalizations: [{ | ||
to: '[email protected]', | ||
headers: { | ||
'test-header': 'test', | ||
}, | ||
substitutions: { | ||
test2: 'Test2', | ||
}, | ||
dynamicTemplateData: { | ||
test2: 'Testy 2', | ||
test3: 'Testy 3', | ||
}, | ||
}], | ||
dynamicTemplateData: { | ||
test1: 'Test 1', | ||
test2: 'Test 2', | ||
}, | ||
substitutions: { | ||
test1: 'Test1', | ||
}, | ||
from: { | ||
email: '[email protected]', | ||
}, | ||
templateId: 'd-df80613cccc6441ea5cd7c95377bc1ef', | ||
subject: 'test', | ||
content: [{ | ||
type: 'text/plain', | ||
value: 'test', | ||
}], | ||
}); | ||
expect(mail.substitutions).to.equal(null); | ||
expect(mail.personalizations[0].substitutions).to.deep.equal({}); | ||
|
||
expect(mail.dynamicTemplateData).to.deep.equal({ test1: 'Test 1', test2: 'Test 2' }); | ||
expect(mail.personalizations[0].dynamicTemplateData).to.deep.equal({ test1: 'Test 1', test2: 'Testy 2', test3: 'Testy 3' }); | ||
|
||
expect(mail.toJSON()).to.deep.equal({ | ||
'content': [ | ||
{ | ||
'type': 'text/plain', | ||
'value': 'test', | ||
}, | ||
], | ||
'from': { | ||
'email': '[email protected]', | ||
}, | ||
'personalizations': [ | ||
{ | ||
'dynamic_template_data': { | ||
'test1': 'Test 1', | ||
'test2': 'Testy 2', | ||
'test3': 'Testy 3', | ||
}, | ||
'headers': { | ||
'test-header': 'test', | ||
}, | ||
'to': [ | ||
{ | ||
'email': '[email protected]', | ||
'name': '', | ||
}, | ||
], | ||
}, | ||
], | ||
'subject': 'test', | ||
'template_id': 'd-df80613cccc6441ea5cd7c95377bc1ef', | ||
}); | ||
}); | ||
|
||
}); | ||
}); |
Oops, something went wrong.