-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
65 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
'use strict'; | ||
|
||
var api = 'message-events'; | ||
|
||
/* | ||
* "Class" declaration, Message Events API exposes one function: | ||
* - search: retrieves list of message events according to given params | ||
*/ | ||
module.exports = function (client) { | ||
return { | ||
search: function(parameters, callback) { | ||
var options = { | ||
uri: api | ||
, qs: parameters | ||
}; | ||
client.get(options, callback); | ||
} | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
var chai = require('chai') | ||
, expect = chai.expect | ||
, sinon = require('sinon') | ||
, sinonChai = require('sinon-chai'); | ||
|
||
chai.use(sinonChai); | ||
|
||
describe('Message Events Library', function() { | ||
var client, templates; | ||
|
||
beforeEach(function() { | ||
client = { | ||
get: sinon.stub().yields() | ||
}; | ||
|
||
messageEvents = require('../../lib/messageEvents')(client); | ||
}); | ||
|
||
describe('search Method', function() { | ||
it('should call client get method with the appropriate parameters', function(done) { | ||
var options = { | ||
bounce_classes: [10, 50], | ||
campaign_ids: 'test_campaign', | ||
events: ['bounce'], | ||
friendly_froms: ['bob@example.com'], | ||
from: '2015-11-14T16:15', | ||
message_ids: ['0e0d94b7-9085-4e3c-ab30-e3f2cd9c273e'], | ||
page: 1, | ||
per_page: 5, | ||
reason: '%5.2.0%', | ||
recipients: ['jim@example.com'], | ||
template_ids: ['newsletter_template'], | ||
timezone: 'America/New_York', | ||
to: '2016-11-14T16:15', | ||
transmission_ids: ['65832150921904138'] | ||
}; | ||
messageEvents.search(options, function(err, data) { | ||
Object.keys(options).forEach(function(key) { | ||
expect(client.get.firstCall.args[0].qs).to.have.property(key).and.equal(options[key]); | ||
}); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
}); |