Skip to content

Commit

Permalink
Merge pull request #38 from sendwithus/add-resend-test
Browse files Browse the repository at this point in the history
Add resend test, update readme, and increment version
  • Loading branch information
phil-swu authored Feb 8, 2018
2 parents e0aed41 + afdb8a4 commit b5f313f
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 23 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,14 @@ api.render({
}
```

# Logs

### Resend
```javascript
var api = require('sendwithus')('API_KEY');
api.resend({"log_id": "log_asdf123456qwerty"}, callback);
```

## Events

* `request: function(method, url, headers, body)` - emitted when a request has been sent to Sendwithus
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sendwithus",
"version": "4.1.0",
"version": "4.2.0",
"author": "Sendwithus <[email protected]>",
"description": "Sendwithus.com Node.js client",
"main": "index.js",
Expand Down
80 changes: 58 additions & 22 deletions test/sendwithus.js
Original file line number Diff line number Diff line change
Expand Up @@ -297,26 +297,62 @@ module.exports.createTemplates = {
};

module.exports.renderTemplates = {
setUp: function (callback) {
this.sendwithus = sendwithusFactory(API_KEY);
this.data = {
template: TEMPLATE,
template_data: {
name: 'name ' + Date().toString()
},
strict: false
};

callback();
},
tearDown: function (callback) {
callback();
},
render: function (test) {
this.sendwithus.render(this.data, function (err, result) {
test.ifError(err);
test.ok(result.success, true);
test.done();
});
}
setUp: function (callback) {
this.sendwithus = sendwithusFactory(API_KEY);
this.data = {
template: TEMPLATE,
template_data: {
name: 'name ' + Date().toString()
},
strict: false
};

callback();
},
tearDown: function (callback) {
callback();
},
render: function (test) {
this.sendwithus.render(this.data, function (err, result) {
test.ifError(err);
test.ok(result.success, true);
test.done();
});
}
};

module.exports.resendLog = {
setUp: function (callback) {
this.sendwithus = sendwithusFactory(API_KEY);
this.data = {
email_id: EMAIL_ID,
recipient: {
address: '[email protected]'
}
};

callback();
},
tearDown: function (callback) {
callback();
},
resend: function (test) {
var that = this;
this.sendwithus.send(this.data, function(err, result) {
test.ifError(err);
test.ok(result.success, true);

var data = {
log_id: result.receipt_id
}

that.sendwithus.resend(data, function (err, result) {
test.ifError(err);
test.ok(result.success, true);
test.done();
});

});
}

}

0 comments on commit b5f313f

Please sign in to comment.