|
15 | 15 |
|
16 | 16 | 'use strict'; |
17 | 17 |
|
18 | | -const proxyquire = require(`proxyquire`).noPreserveCache(); |
19 | | -const assert = require('assert'); |
| 18 | +const proxyquire = require('proxyquire'); |
| 19 | +const {assert} = require('chai'); |
20 | 20 |
|
21 | 21 | process.env.SENDGRID_API_KEY = `foo`; |
22 | 22 |
|
23 | 23 | describe('sendgrid', () => { |
24 | 24 | it('should send an email', () => { |
25 | 25 | proxyquire(`../sendgrid`, { |
26 | | - sendgrid: key => { |
27 | | - assert.strictEqual(key, `foo`); |
28 | | - return { |
29 | | - emptyRequest: x => x, |
30 | | - API: request => { |
31 | | - assert.deepStrictEqual(request, { |
32 | | - method: `POST`, |
33 | | - path: `/v3/mail/send`, |
34 | | - body: { |
35 | | - personalizations: [ |
36 | | - { |
37 | | - to: [{email: `[email protected]`}], |
38 | | - subject: `Sendgrid test email from Node.js on Google Cloud Platform`, |
39 | | - }, |
40 | | - ], |
41 | | - from: {email: `[email protected]`}, |
42 | | - content: [ |
43 | | - { |
44 | | - type: `text/plain`, |
45 | | - value: `Hello!\n\nThis a Sendgrid test email from Node.js on Google Cloud Platform.`, |
46 | | - }, |
47 | | - ], |
48 | | - }, |
49 | | - }); |
50 | | - }, |
51 | | - }; |
| 26 | + '@sendgrid/mail': { |
| 27 | + setApiKey: key => { |
| 28 | + assert.strictEqual(key, `foo`); |
| 29 | + }, |
| 30 | + send: msg => { |
| 31 | + assert.deepStrictEqual(msg, { |
| 32 | + |
| 33 | + |
| 34 | + subject: |
| 35 | + 'Sendgrid test email from Node.js on Google Cloud Platform', |
| 36 | + text: |
| 37 | + 'Well hello! This is a Sendgrid test email from Node.js on Google Cloud Platform.', |
| 38 | + }); |
| 39 | + }, |
52 | 40 | }, |
53 | 41 | }); |
54 | 42 | }); |
|
0 commit comments