|
| 1 | +const { assert } = require('chai'); |
| 2 | + |
| 3 | +const MailService = require('./mail-service'); |
| 4 | +describe('MailService send', () => { |
| 5 | + it('should not mutate original data variable', () => { |
| 6 | + const mailService = new MailService(); |
| 7 | + mailService.setClient({ |
| 8 | + request: (req, cb) => { |
| 9 | + return new Promise((resolve) => { |
| 10 | + resolve(); |
| 11 | + }); |
| 12 | + }, |
| 13 | + }); |
| 14 | + const data = { |
| 15 | + to: 'test@example.com', |
| 16 | + from: 'test@example.com', // Use the email address or domain you verified above |
| 17 | + subject: 'Sending with Twilio SendGrid is Fun', |
| 18 | + text: 'and easy to do anywhere, even with Node.js', |
| 19 | + html: '<strong>and easy to do anywhere, even with Node.js</strong>', |
| 20 | + }; |
| 21 | + return mailService.send(data).then(() => { |
| 22 | + assert.deepStrictEqual(data, |
| 23 | + { |
| 24 | + to: 'test@example.com', |
| 25 | + from: 'test@example.com', // Use the email address or domain you verified above |
| 26 | + subject: 'Sending with Twilio SendGrid is Fun', |
| 27 | + text: 'and easy to do anywhere, even with Node.js', |
| 28 | + html: '<strong>and easy to do anywhere, even with Node.js</strong>', |
| 29 | + }); |
| 30 | + |
| 31 | + }); |
| 32 | + }); |
| 33 | +}); |
0 commit comments