Skip to content

bcoe/nodemailer-mock-transport

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

nodemailer-mock-transport

Build Status Coverage Status

Mock nodemailer-transport, for testing services that rely on nodemailer.

describe('mock-transport', function() {
  it('should store configuration options so that they can be asserted against', function() {
    var transport = mockTransport({
      foo: 'bar'
    });
    transport.options.foo.should.equal('bar');
  });

  it('should store emails sent with nodemailer, so that they can be asserted against', function() {
    var transport = mockTransport({
      foo: 'bar'
    });

    var transporter = nodemailer.createTransport(transport);

    transporter.sendMail({
      from: 'sender@address',
      to: 'receiver@address',
      subject: 'hello',
      text: 'hello world!'
    });

    transport.sentMail.length.should.equal(1);
    transport.sentMail[0].data.to.should.equal('receiver@address');
    transport.sentMail[0].message.content.should.equal('hello world!');
  });

  it('should return an error and not send an email if there is no `to` in the mail data object', function () {
    var transport = mockTransport({
      foo: 'bar'
    });

    var transporter = nodemailer.createTransport(transport);

    transporter.sendMail({
      from: 'sender@address',
      subject: 'hello',
      text: 'hello world!'
    });

    transport.sentMail.length.should.equal(0);
  });
});

About

mock-mailer for putting tests around services that use node-mailer

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors 4

  •  
  •  
  •  
  •