|
| 1 | +// Copyright 2016, Google, Inc. |
| 2 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 3 | +// you may not use this file except in compliance with the License. |
| 4 | +// You may obtain a copy of the License at |
| 5 | +// |
| 6 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 7 | +// |
| 8 | +// Unless required by applicable law or agreed to in writing, software |
| 9 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 10 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 11 | +// See the License for the specific language governing permissions and |
| 12 | +// limitations under the License. |
| 13 | + |
| 14 | +'use strict'; |
| 15 | + |
| 16 | +var proxyquire = require('proxyquire').noPreserveCache(); |
| 17 | +process.env.MAILJET_API_KEY = 'foo'; |
| 18 | +process.env.MAILJET_API_SECRET = 'bar'; |
| 19 | + |
| 20 | +describe('computeengine:mailjet', function () { |
| 21 | + it('should send an email', function (done) { |
| 22 | + proxyquire('../mailjet', { |
| 23 | + nodemailer: { |
| 24 | + createTransport: function (arg) { |
| 25 | + assert.equal(arg, 'test'); |
| 26 | + return { |
| 27 | + sendMail: function (payload, cb) { |
| 28 | + assert.deepEqual(payload, { |
| 29 | + from: 'ANOTHER_EMAIL@ANOTHER_EXAMPLE.COM', |
| 30 | + |
| 31 | + subject: 'test email from Node.js on Google Cloud Platform', |
| 32 | + text: 'Hello!\n\nThis a test email from Node.js.' |
| 33 | + }); |
| 34 | + cb('done'); |
| 35 | + done(); |
| 36 | + } |
| 37 | + }; |
| 38 | + } |
| 39 | + }, |
| 40 | + 'nodemailer-smtp-transport': function (options) { |
| 41 | + assert.deepEqual(options, { |
| 42 | + host: 'in.mailjet.com', |
| 43 | + port: 2525, |
| 44 | + auth: { |
| 45 | + user: 'foo', |
| 46 | + pass: 'bar' |
| 47 | + } |
| 48 | + }); |
| 49 | + return 'test'; |
| 50 | + } |
| 51 | + }); |
| 52 | + }); |
| 53 | +}); |
0 commit comments