summaryrefslogtreecommitdiffstats
path: root/test/lib/email.test.js
blob: 1db7065b56e1d3938272696e4648cae18bf82d4a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
var Email = require('../../lib/email');

var text_params = {
  to: 'david.tomberlin@sendgrid.com',
  from: 'kyle.partridge@sendgrid.com',
  subject: 'Subject',
  text: 'This is an email.'
};

describe('Email', function () {
  it('should allow attributes to be set in the constuctor', function() {
    var mail = new Email(text_params);

    for (var key in text_params) {
      text_params[key].should.eql(mail.params[key]);
    }
  });

  describe('validation', function() {
    it('should invalidate when there are no parameters', function() {
      var mail = new Email();

      mail.validate().should.be.false;
    });

    it('should return true when the mail is valid', function() {
      var mail = new Email(text_params);

      mail.validate().should.be.true;
    });
  });
});