Moved WebAPI tests to mocks instead of real requests. #49

Closed
wants to merge 4 commits into
from

Projects

None yet

1 participant

@theycallmeswift
Contributor

Original integration tests sent out actual emails using credentials from a config file. Now they use a mocked http request to SendGrid and we test that the request is what we would expect.

This is part of #48

theycallmeswift added some commits Dec 27, 2012
@theycallmeswift theycallmeswift Moved WebAPI tests to mocks instead of real requests.
Original integration tests sent out actual emails using credentials from
a config file.  Now they use a mocked http request to SendGrid and we
test that the request is what we would expect.

This is part of #48
b87315f
@theycallmeswift theycallmeswift Added nock as a dependency and updated shrinkwrap 1bdc481
@theycallmeswift theycallmeswift commented on the diff Dec 28, 2012
test/lib/sendgrid.test.js
+ expect(postParams).not.to.include.keys(['toname', 'fromname']);
+
+ expect(postParams.api_user).to.equal('some_sendgrid_username');
+ expect(postParams.api_key).to.equal('some_sendgrid_password');
+ expect(postParams.to).to.equal('hello@example.com');
+ expect(postParams.from).to.equal('swift@sendgrid.com');
+ expect(postParams.subject).to.equal('Test subject');
+ expect(postParams.text).to.equal('This is a text body');
+ expect(postParams.html).to.equal('<p>This is an html body</p>');
+ expect(postParams['x-smtpapi']).to.equal('{}');
+
+ done();
+ });
+ });
+
+ it('supports an optional toname and fromname', function(done) {
@theycallmeswift
theycallmeswift Dec 28, 2012 Contributor

This should probably be moved to the email.js tests since it has nothing to do with the actual #send method

@theycallmeswift theycallmeswift added a commit that closed this pull request Mar 25, 2013
@theycallmeswift theycallmeswift Moved WebAPI tests to mocks instead of real requests.
Original integration tests sent out actual emails using credentials from
a config file.  Now they use a mocked http request to SendGrid and we
test that the request is what we would expect.

This is part of #48

Closes #49
8f8cfc5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment