Socket
Socket
Sign inDemoInstall

sparkpost

Package Overview
Dependencies
Maintainers
4
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sparkpost - npm Package Compare versions

Comparing version 2.1.1 to 2.1.2

lib/withCallback.js

7

CHANGELOG.md

@@ -7,2 +7,6 @@ # Change Log

## [2.1.2] - 2017-01-20
### Fixed
- Callbacks are no longer being called twice in some methods by @avrahamgoldman. See Issue [203](https://github.com/SparkPost/node-sparkpost/issues/203).
## [2.1.1] - 2017-01-11

@@ -160,3 +164,4 @@ ### Changed

[unreleased]: https://github.com/sparkpost/node-sparkpost/compare/v2.1.1...HEAD
[unreleased]: https://github.com/sparkpost/node-sparkpost/compare/v2.1.2...HEAD
[2.1.2]: https://github.com/sparkpost/node-sparkpost/compare/v2.1.1...v2.1.2
[2.1.1]: https://github.com/sparkpost/node-sparkpost/compare/v2.1.0...v2.1.1

@@ -163,0 +168,0 @@ [2.1.0]: https://github.com/sparkpost/node-sparkpost/compare/v2.0.1...v2.1.0

15

lib/inboundDomains.js
'use strict';
const withCallback = require('./Promise');
const api = 'inbound-domains';

@@ -18,3 +17,3 @@

};
return withCallback(client.get(options), callback);
return client.get(options, callback);
},

@@ -30,3 +29,3 @@ /**

if (!domain || typeof domain !== 'string') {
return withCallback(Promise.reject(new Error('domain is required')), callback);
return client.reject(new Error('domain is required'), callback);
}

@@ -37,3 +36,3 @@

};
return withCallback(client.get(options), callback);
return client.get(options, callback);
},

@@ -49,3 +48,3 @@ /**

if (!createOpts || typeof createOpts !== 'object') {
return withCallback(Promise.reject(new Error('create options are required')), callback);
return client.reject(new Error('create options are required'), callback);
}

@@ -57,3 +56,3 @@

};
return withCallback(client.post(options, callback), callback);
return client.post(options, callback);
},

@@ -69,3 +68,3 @@ /**

if (!domain || typeof domain !== 'string') {
return withCallback(Promise.reject(new Error('domain is required')), callback);
return client.reject(new Error('domain is required'), callback);
}

@@ -76,5 +75,5 @@

};
return withCallback(client.delete(options), callback);
return client.delete(options, callback);
}
};
};
'use strict';
const withCallback = require('./Promise');
const api = 'message-events';

@@ -32,5 +31,5 @@

});
return withCallback(client.get(options), callback);
return client.get(options, callback);
}
};
};
'use strict';
const withCallback = require('./Promise');
const api = 'recipient-lists';

@@ -19,3 +18,3 @@

};
return withCallback(client.get(reqOpts), callback);
return client.get(reqOpts, callback);
},

@@ -42,3 +41,3 @@

if (!id) {
return withCallback(Promise.reject(new Error('id is required')), callback);
return client.reject(new Error('id is required'), callback);
}

@@ -51,3 +50,3 @@

return withCallback(client.get(reqOpts), callback);
return client.get(reqOpts, callback);
},

@@ -67,3 +66,3 @@

if (!recipientList || typeof recipientList !== 'object' || !recipientList.recipients) {
return withCallback(Promise.reject(new Error('recipient list is required')), callback);
return client.reject(new Error('recipient list is required'), callback);
}

@@ -79,3 +78,3 @@

return withCallback(client.post(reqOpts), callback);
return client.post(reqOpts, callback);
},

@@ -96,7 +95,7 @@

if (!id) {
return withCallback(Promise.reject(new Error('recipient list id is required')), callback);
return client.reject(new Error('recipient list id is required'), callback);
}
if (!recipientList || typeof recipientList === 'function') {
return withCallback(Promise.reject(new Error('recipient list is required')), callback);
return client.reject(new Error('recipient list is required'), callback);
}

@@ -112,3 +111,3 @@

return withCallback(client.put(reqOpts), callback);
return client.put(reqOpts, callback);
},

@@ -127,3 +126,3 @@

if (!id || typeof id !== 'string') {
return withCallback(Promise.reject(new Error('id is required')), callback);
return client.reject(new Error('id is required'), callback);
}

@@ -135,3 +134,3 @@

return withCallback(client.delete(reqOpts), callback);
return client.delete(reqOpts, callback);
}

@@ -138,0 +137,0 @@ };

'use strict';
const withCallback = require('./Promise');
const api = 'relay-webhooks';

@@ -18,3 +17,3 @@

};
return withCallback(client.get(reqOpts), callback);
return client.get(reqOpts, callback);
},

@@ -30,3 +29,3 @@ /**

if (!id || typeof id !== 'string') {
return withCallback(Promise.reject(new Error('id is required')), callback);
return client.reject(new Error('id is required'), callback);
}

@@ -38,3 +37,3 @@

return withCallback(client.get(options), callback);
return client.get(options, callback);
},

@@ -50,3 +49,3 @@ /**

if (!webhook || typeof webhook !== 'object') {
return withCallback(Promise.reject(new Error('webhook object is required')), callback);
return client.reject(new Error('webhook object is required'), callback);
}

@@ -59,3 +58,3 @@

return withCallback(client.post(reqOpts), callback);
return client.post(reqOpts, callback);
},

@@ -72,7 +71,7 @@ /**

if (!id || typeof id !== 'string') {
return withCallback(Promise.reject(new Error('id is required')), callback);
return client.reject(new Error('id is required'), callback);
}
if (!webhook || typeof webhook !== 'object') {
return withCallback(Promise.reject(new Error('webhook object is required')), callback);
return client.reject(new Error('webhook object is required'), callback);
}

@@ -85,3 +84,3 @@

return withCallback(client.put(reqOpts), callback);
return client.put(reqOpts, callback);
},

@@ -97,3 +96,3 @@ /**

if (!id || typeof id !== 'string') {
return withCallback(Promise.reject(new Error('id is required')), callback);
return client.reject(new Error('id is required'), callback);
}

@@ -105,5 +104,5 @@

return withCallback(client.delete(options, callback), callback);
return client.delete(options, callback);
}
};
};
'use strict';
const withCallback = require('./Promise');
const api = 'sending-domains';
module.exports = function(client) {
return {

@@ -20,3 +18,3 @@ /**

return withCallback(client.get(options), callback);
return client.get(options, callback);
},

@@ -33,3 +31,3 @@

if (!domain || typeof domain === 'function') {
return withCallback(Promise.reject(new Error('domain is required')), callback);
return client.reject(new Error('domain is required'), callback);
}

@@ -41,3 +39,3 @@

return withCallback(client.get(options), callback);
return client.get(options, callback);
},

@@ -54,3 +52,3 @@

if (!createOpts || typeof createOpts !== 'object') {
return withCallback(Promise.reject(new Error('create options are required')), callback);
return client.reject(new Error('create options are required'), callback);
}

@@ -63,3 +61,3 @@

return withCallback(client.post(options), callback);
return client.post(options, callback);
},

@@ -77,7 +75,7 @@

if (typeof domain !== 'string') {
return withCallback(Promise.reject(new Error('domain is required')), callback);
return client.reject(new Error('domain is required'), callback);
}
if (!updateOpts || typeof updateOpts !== 'object') {
return withCallback(Promise.reject(new Error('update options are required')), callback);
return client.reject(new Error('update options are required'), callback);
}

@@ -90,3 +88,3 @@

return withCallback(client.put(options), callback);
return client.put(options, callback);
},

@@ -103,3 +101,3 @@

if (typeof domain !== 'string') {
return withCallback(Promise.reject(new Error('domain is required')), callback);
return client.reject(new Error('domain is required'), callback);
}

@@ -111,3 +109,3 @@

return withCallback(client.delete(options), callback);
return client.delete(options, callback);
},

@@ -125,7 +123,7 @@

if (typeof domain !== 'string') {
return withCallback(Promise.reject(new Error('domain is required')), callback);
return client.reject(new Error('domain is required'), callback);
}
if (!options || typeof options !== 'object') {
return withCallback(Promise.reject(new Error('verification options are required')), callback);
return client.reject(new Error('verification options are required'), callback);
}

@@ -138,3 +136,3 @@

return withCallback(client.post(reqOpts), callback);
return client.post(reqOpts, callback);
}

@@ -141,0 +139,0 @@ };

@@ -5,3 +5,3 @@ 'use strict';

const url = require('url');
const withCallback = require('./Promise');
const withCallback = require('./withCallback');
const request = require('request');

@@ -145,3 +145,3 @@ const _ = require('lodash');

return withCallback(this.request(options), callback);
return this.request(options, callback);
};

@@ -152,3 +152,3 @@

return withCallback(this.request(options), callback);
return this.request(options, callback);
};

@@ -159,3 +159,3 @@

return withCallback(this.request(options), callback);
return this.request(options, callback);
};

@@ -166,5 +166,9 @@

return withCallback(this.request(options), callback);
return this.request(options, callback);
};
SparkPost.prototype.reject = function(error, callback) {
return withCallback(Promise.reject(error), callback);
};
module.exports = SparkPost;

@@ -171,0 +175,0 @@

'use strict';
const withCallback = require('./Promise');
const api = 'subaccounts';

@@ -18,3 +17,3 @@

};
return withCallback(client.get(options), callback);
return client.get(options, callback);
},

@@ -30,3 +29,3 @@ /**

if (!id || typeof id !== 'string') {
return withCallback(Promise.reject(new Error('id is required')), callback);
return client.reject(new Error('id is required'), callback);
}

@@ -37,3 +36,3 @@

};
return withCallback(client.get(options), callback);
return client.get(options, callback);
},

@@ -49,3 +48,3 @@ /**

if (!subaccount || typeof subaccount !== 'object') {
return withCallback(Promise.reject(new Error('subaccount object is required')), callback);
return client.reject(new Error('subaccount object is required'), callback);
}

@@ -57,3 +56,3 @@

};
return withCallback(client.post(reqOpts), callback);
return client.post(reqOpts, callback);
},

@@ -70,7 +69,7 @@ /**

if (!id || typeof id !== 'string') {
return withCallback(Promise.reject(new Error('id is required')), callback);
return client.reject(new Error('id is required'), callback);
}
if (!subaccount || typeof subaccount !== 'object') {
return withCallback(Promise.reject(new Error('subaccount object is required')), callback);
return client.reject(new Error('subaccount object is required'), callback);
}

@@ -83,3 +82,3 @@

return withCallback(client.put(reqOpts), callback);
return client.put(reqOpts, callback);
}

@@ -86,0 +85,0 @@ };

'use strict';
const withCallback = require('./Promise');
const api = 'suppression-list';

@@ -22,3 +21,3 @@

};
return withCallback(client.get(options), callback);
return client.get(options, callback);
},

@@ -35,3 +34,3 @@

if (!email || typeof email === 'function') {
return withCallback(Promise.reject(new Error('email is required')), callback);
return client.reject(new Error('email is required'), callback);
}

@@ -42,3 +41,3 @@

};
return withCallback(client.get(options), callback);
return client.get(options, callback);
},

@@ -56,3 +55,3 @@

if (!listEntries || typeof listEntries === 'function') {
return withCallback(Promise.reject(new Error('list entries is required')), callback);
return client.reject(new Error('list entries is required'), callback);
}

@@ -69,3 +68,3 @@

return withCallback(client.put(options, callback), callback);
return client.put(options, callback);
},

@@ -82,3 +81,3 @@

if (!email || typeof email === 'function') {
return withCallback(Promise.reject(new Error('email is required')), callback);
return client.reject(new Error('email is required'), callback);
}

@@ -89,3 +88,3 @@

};
return withCallback(client.delete(options), callback);
return client.delete(options, callback);
}

@@ -92,0 +91,0 @@ };

'use strict';
const withCallback = require('./Promise');
const api = 'templates';

@@ -20,3 +19,3 @@

};
return withCallback(client.get(options), callback);
return client.get(options, callback);
},

@@ -40,3 +39,3 @@ /**

if (!id) {
return withCallback(Promise.reject(new Error('template id is required')), callback);
return client.reject(new Error('template id is required'), callback);
}

@@ -49,3 +48,3 @@

return withCallback(client.get(reqOpts), callback);
return client.get(reqOpts, callback);
},

@@ -61,3 +60,3 @@ /**

if (!template || typeof template !== 'object') {
return withCallback(Promise.reject(new Error('template object is required')), callback);
return client.reject(new Error('template object is required'), callback);
}

@@ -70,3 +69,3 @@

return withCallback(client.post(reqOpts), callback);
return client.post(reqOpts, callback);
},

@@ -90,7 +89,7 @@ /**

if (!id) {
return withCallback(Promise.reject(new Error('template id is required')), callback);
return client.reject(new Error('template id is required'), callback);
}
if (!template || typeof template !== 'object') {
return withCallback(Promise.reject(new Error('template object is required')), callback);
return client.reject(new Error('template object is required'), callback);
}

@@ -104,3 +103,3 @@

return withCallback(client.put(reqOpts), callback);
return client.put(reqOpts, callback);
},

@@ -116,3 +115,3 @@ /**

if (!id || typeof id !== 'string') {
return withCallback(Promise.reject(new Error('template id is required')), callback);
return client.reject(new Error('template id is required'), callback);
}

@@ -123,3 +122,3 @@

};
return withCallback(client.delete(options), callback);
return client.delete(options, callback);
},

@@ -144,3 +143,3 @@ /**

if (!id) {
return withCallback(Promise.reject(new Error('template id is required')), callback);
return client.reject(new Error('template id is required'), callback);
}

@@ -159,5 +158,5 @@

return withCallback(client.post(reqOpts), callback);
return client.post(reqOpts, callback);
}
};
};
'use strict';
const _ = require('lodash');
const withCallback = require('./Promise');
const api = 'transmissions';

@@ -13,3 +12,2 @@

module.exports = function(client) {
return {

@@ -35,3 +33,3 @@ /**

return withCallback(client.get(reqOpts), callback);
return client.get(reqOpts, callback);
},

@@ -47,3 +45,3 @@ /**

if (typeof id !== 'string') {
return withCallback(Promise.reject(new Error('id is required')), callback);
return client.reject(new Error('id is required'), callback);
}

@@ -55,3 +53,3 @@

return withCallback(client.get(options), callback);
return client.get(options, callback);
},

@@ -74,3 +72,3 @@ /**

if (!transmission || typeof transmission !== 'object') {
return withCallback(Promise.reject(new Error('transmission object is required')), callback);
return client.reject(new Error('transmission object is required'), callback);
}

@@ -86,3 +84,3 @@

return withCallback(client.post(reqOpts), callback);
return client.post(reqOpts, callback);
}

@@ -89,0 +87,0 @@ };

'use strict';
const withCallback = require('./Promise');
const api = 'webhooks';

@@ -32,3 +31,3 @@

return withCallback(client.get(reqOpts), callback);
return client.get(reqOpts, callback);
},

@@ -52,3 +51,3 @@

if (typeof id !== 'string') {
return withCallback(Promise.reject(new Error('id is required')), callback);
return client.reject(new Error('id is required'), callback);
}

@@ -65,3 +64,3 @@

return withCallback(client.get(reqOpts), callback);
return client.get(reqOpts, callback);
},

@@ -78,3 +77,3 @@

if (!webhook || typeof webhook === 'function') {
return withCallback(Promise.reject(new Error('webhook object is required')), callback);
return client.reject(new Error('webhook object is required'), callback);
}

@@ -87,3 +86,3 @@

return withCallback(client.post(options), callback);
return client.post(options, callback);
},

@@ -101,7 +100,7 @@

if (!id) {
return withCallback(Promise.reject(new Error('id is required')), callback);
return client.reject(new Error('id is required'), callback);
}
if (!webhook || typeof webhook === 'function') {
return withCallback(Promise.reject(new Error('webhook object is required')), callback);
return client.reject(new Error('webhook object is required'), callback);
}

@@ -116,3 +115,3 @@

return withCallback(client.put(options), callback);
return client.put(options, callback);
},

@@ -129,3 +128,3 @@

if (!id || typeof id === 'function') {
return withCallback(Promise.reject(new Error('id is required')), callback);
return client.reject(new Error('id is required'), callback);
}

@@ -137,3 +136,3 @@

return withCallback(client.delete(options), callback);
return client.delete(options, callback);
},

@@ -152,7 +151,7 @@

if (typeof id !== 'string') {
return withCallback(Promise.reject(new Error('id is required')), callback);
return client.reject(new Error('id is required'), callback);
}
if (!options || typeof options === 'function' || !options.message) {
return withCallback(Promise.reject(new Error('message is required')), callback);
return client.reject(new Error('message is required'), callback);
}

@@ -167,3 +166,3 @@

return withCallback(client.post(reqOpts), callback);
return client.post(reqOpts, callback);
},

@@ -187,3 +186,3 @@

if (typeof id !== 'string') {
return withCallback(Promise.reject(new Error('id is required')), callback);
return client.reject(new Error('id is required'), callback);
}

@@ -200,3 +199,3 @@

return withCallback(client.get(reqOpts), callback);
return client.get(reqOpts, callback);
},

@@ -214,3 +213,3 @@

};
return withCallback(client.get(reqOpts), callback);
return client.get(reqOpts, callback);
},

@@ -241,5 +240,5 @@

return withCallback(client.get(reqOpts), callback);
return client.get(reqOpts, callback);
}
};
};
{
"name": "sparkpost",
"version": "2.1.1",
"version": "2.1.2",
"description": "A Node.js wrapper for interfacing with your favorite SparkPost APIs",

@@ -5,0 +5,0 @@ "main": "./lib/sparkpost.js",

@@ -5,2 +5,3 @@ 'use strict';

, expect = chai.expect
, SparkPost = require('../../lib/sparkpost')
, sinon = require('sinon');

@@ -14,3 +15,3 @@

describe('Inbound Domains Library', function() {
let client, inboundDomains;
let client, inboundDomains, callback;

@@ -21,5 +22,8 @@ beforeEach(function() {

post: sinon.stub().resolves({}),
delete: sinon.stub().resolves({})
delete: sinon.stub().resolves({}),
reject: SparkPost.prototype.reject
};
callback = function() {};
inboundDomains = require('../../lib/inboundDomains')(client);

@@ -30,5 +34,7 @@ });

it('should call client get method with the appropriate uri', function() {
return inboundDomains.list()
return inboundDomains.list(callback)
.then(function() {
expect(client.get.firstCall.args[0]).to.deep.equal({uri: 'inbound-domains'});
expect(client.get.firstCall.args[1]).to.equal(callback);
});

@@ -40,8 +46,10 @@ });

it('should call client get method with the appropriate uri', function() {
return inboundDomains.get('test')
return inboundDomains.get('test', callback)
.then(function() {
expect(client.get.firstCall.args[0]).to.deep.equal({uri: 'inbound-domains/test'});
expect(client.get.firstCall.args[1]).to.equal(callback);
});
});
it('should throw an error if domain is missing', function() {

@@ -55,6 +63,7 @@ return expect(inboundDomains.get()).to.be.rejectedWith('domain is required');

let createOpts = {domain: 'test'};
return inboundDomains.create(createOpts)
return inboundDomains.create(createOpts, callback)
.then(function() {
expect(client.post.firstCall.args[0].uri).to.equal('inbound-domains');
expect(client.post.firstCall.args[0].json).to.deep.equal(createOpts);
expect(client.post.firstCall.args[1]).to.equal(callback);
});

@@ -70,5 +79,6 @@ });

it('should call client delete method with the appropriate uri', function() {
return inboundDomains.delete('test')
return inboundDomains.delete('test', callback)
.then(function () {
expect(client.delete.firstCall.args[0].uri).to.equal('inbound-domains/test');
expect(client.delete.firstCall.args[1]).to.equal(callback);
});

@@ -75,0 +85,0 @@ });

@@ -5,4 +5,3 @@ 'use strict';

, expect = chai.expect
, sinon = require('sinon')
, Promise = require('../../lib/Promise');
, sinon = require('sinon');

@@ -15,3 +14,3 @@ require('sinon-as-promised');

describe('Message Events Library', function() {
let client, messageEvents;
let client, messageEvents, callback;

@@ -23,2 +22,4 @@ beforeEach(function() {

callback = function() {};
messageEvents = require('../../lib/messageEvents')(client);

@@ -45,3 +46,3 @@ });

};
return messageEvents.search(options)
return messageEvents.search(options, callback)
.then(function() {

@@ -51,2 +52,3 @@ Object.keys(options).forEach(function(key) {

});
expect(client.get.firstCall.args[1]).to.equal(callback);
});

@@ -53,0 +55,0 @@ });

@@ -6,2 +6,3 @@ 'use strict';

, expect = chai.expect
, SparkPost = require('../../lib/sparkpost')
, sinon = require('sinon');

@@ -15,3 +16,3 @@

describe('Recipient Lists Library', function() {
var client, recipientLists;
var client, recipientLists, callback;

@@ -23,5 +24,8 @@ beforeEach(function() {

put: sinon.stub().resolves({}),
delete: sinon.stub().resolves({})
delete: sinon.stub().resolves({}),
reject: SparkPost.prototype.reject
};
callback = function() {};
recipientLists = require('../../lib/recipientLists')(client);

@@ -33,8 +37,8 @@ });

it('should call client get method with the appropriate uri', function() {
return recipientLists.list()
return recipientLists.list(callback)
.then(function() {
expect(client.get.firstCall.args[0].uri).to.equal('recipient-lists');
expect(client.get.firstCall.args[1]).to.equal(callback);
});
});
});

@@ -45,5 +49,6 @@

it('should call client get method with the appropriate uri', function() {
return recipientLists.get('test-id')
return recipientLists.get('test-id', callback)
.then(function() {
expect(client.get.firstCall.args[0].uri).to.equal('recipient-lists/test-id');
expect(client.get.firstCall.args[1]).to.equal(callback);
});

@@ -58,2 +63,5 @@ });

let cb = sinon.stub();
client.get.yields();
return recipientLists.get('test-id', cb).then(() => {

@@ -92,6 +100,7 @@ expect(cb.callCount).to.equal(1);

return recipientLists.create(testList)
return recipientLists.create(testList, callback)
.then(function() {
expect(client.post.firstCall.args[0].uri).to.equal('recipient-lists');
expect(client.post.firstCall.args[0].json).to.deep.equal(testList);
expect(client.post.firstCall.args[1]).to.equal(callback);
});

@@ -145,6 +154,7 @@ });

return recipientLists.update(testId, testList)
return recipientLists.update(testId, testList, callback)
.then(function() {
expect(client.put.firstCall.args[0].uri).to.equal('recipient-lists/' + testId);
expect(client.put.firstCall.args[0].json).to.deep.equal(testList);
expect(client.put.firstCall.args[1]).to.equal(callback);
});

@@ -185,5 +195,6 @@ });

it('should call client delete method with the appropriate uri', function() {
return recipientLists.delete('test')
return recipientLists.delete('test', callback)
.then(function() {
expect(client.delete.firstCall.args[0].uri).to.equal('recipient-lists/test');
expect(client.delete.firstCall.args[1]).to.equal(callback);
});

@@ -190,0 +201,0 @@ });

@@ -5,2 +5,3 @@ 'use strict';

, expect = chai.expect
, SparkPost = require('../../lib/sparkpost')
, sinon = require('sinon');

@@ -14,3 +15,3 @@

describe('Relay Webhooks Library', function() {
let client, relayWebhooks;
let client, relayWebhooks, callback;

@@ -22,5 +23,8 @@ beforeEach(function() {

put: sinon.stub().resolves({}),
delete: sinon.stub().resolves({})
delete: sinon.stub().resolves({}),
reject: SparkPost.prototype.reject
};
callback = function() {};
relayWebhooks = require('../../lib/relayWebhooks')(client);

@@ -31,5 +35,6 @@ });

it('should call client get method with the appropriate uri', function() {
return relayWebhooks.list()
return relayWebhooks.list(callback)
.then(function() {
expect(client.get.firstCall.args[0].uri).to.equal('relay-webhooks');
expect(client.get.firstCall.args[1]).to.equal(callback);
});

@@ -41,5 +46,6 @@ });

it('should call client get method with the appropriate uri', function() {
return relayWebhooks.get('test')
return relayWebhooks.get('test', callback)
.then(function() {
expect(client.get.firstCall.args[0]).to.deep.equal({uri: 'relay-webhooks/test'});
expect(client.get.firstCall.args[1]).to.equal(callback);
});

@@ -60,6 +66,7 @@ });

return relayWebhooks.create(webhook)
return relayWebhooks.create(webhook, callback)
.then(function() {
expect(client.post.firstCall.args[0].uri).to.equal('relay-webhooks');
expect(client.post.firstCall.args[0].json).to.deep.equal(webhook);
expect(client.post.firstCall.args[1]).to.equal(callback);
});

@@ -79,6 +86,7 @@ });

return relayWebhooks.update('test', webhook)
return relayWebhooks.update('test', webhook, callback)
.then(function() {
expect(client.put.firstCall.args[0].uri).to.equal('relay-webhooks/test');
expect(client.put.firstCall.args[0].json).to.deep.equal(webhook);
expect(client.put.firstCall.args[1]).to.equal(callback);
});

@@ -98,5 +106,6 @@ });

it('should call client delete method with the appropriate uri', function() {
return relayWebhooks.delete('test')
return relayWebhooks.delete('test', callback)
.then(function() {
expect(client.delete.firstCall.args[0].uri).to.equal('relay-webhooks/test');
expect(client.delete.firstCall.args[1]).to.equal(callback);
});

@@ -103,0 +112,0 @@ });

@@ -6,2 +6,3 @@ 'use strict';

, expect = chai.expect
, SparkPost = require('../../lib/sparkpost')
, sinon = require('sinon');

@@ -15,3 +16,3 @@

describe('Sending Domains Library', function() {
var client, sendingDomains;
var client, sendingDomains, callback;

@@ -23,5 +24,8 @@ beforeEach(function() {

put: sinon.stub().resolves({}),
delete: sinon.stub().resolves({})
delete: sinon.stub().resolves({}),
reject: SparkPost.prototype.reject
};
callback = function() {};
sendingDomains = require('../../lib/sendingDomains')(client);

@@ -32,5 +36,6 @@ });

it('should call client get method with the appropriate uri', function() {
return sendingDomains.list()
return sendingDomains.list(callback)
.then(function() {
expect(client.get.firstCall.args[0]).to.deep.equal({uri: 'sending-domains'});
expect(client.get.firstCall.args[1]).to.equal(callback);
});

@@ -42,5 +47,6 @@ });

it('should call client get method with the appropriate uri', function() {
return sendingDomains.get('test')
return sendingDomains.get('test', callback)
.then(function() {
expect(client.get.firstCall.args[0]).to.deep.equal({uri: 'sending-domains/test'});
expect(client.get.firstCall.args[1]).to.equal(callback);
});

@@ -60,5 +66,6 @@ });

return sendingDomains.create(sendingDomain).then(function() {
return sendingDomains.create(sendingDomain, callback).then(function() {
expect(client.post.firstCall.args[0].uri).to.equal('sending-domains');
expect(client.post.firstCall.args[0].json).to.deep.equal(sendingDomain);
expect(client.post.firstCall.args[1]).to.equal(callback);
});

@@ -78,6 +85,7 @@ });

return sendingDomains.update('test', sendingDomain)
return sendingDomains.update('test', sendingDomain, callback)
.then(function() {
expect(client.put.firstCall.args[0].uri).to.equal('sending-domains/test');
expect(client.put.firstCall.args[0].json).to.deep.equal(_.omit(sendingDomain, 'domain'));
expect(client.put.firstCall.args[1]).to.equal(callback);
});

@@ -97,5 +105,6 @@ });

it('should call client delete method with the appropriate uri', function() {
return sendingDomains.delete('test')
return sendingDomains.delete('test', callback)
.then(function() {
expect(client.delete.firstCall.args[0].uri).to.equal('sending-domains/test');
expect(client.delete.firstCall.args[1]).to.equal(callback);
});

@@ -116,6 +125,7 @@ });

return sendingDomains.verify('test', options)
return sendingDomains.verify('test', options, callback)
.then(function() {
expect(client.post.firstCall.args[0].uri).to.equal('sending-domains/test/verify');
expect(client.post.firstCall.args[0].json).to.deep.equal(_.omit(options, 'domain'));
expect(client.post.firstCall.args[1]).to.equal(callback);
});

@@ -132,3 +142,3 @@ });

});
});

@@ -5,2 +5,3 @@ 'use strict';

, expect = chai.expect
, SparkPost = require('../../lib/sparkpost')
, sinon = require('sinon');

@@ -14,3 +15,3 @@

describe('Subaccounts Library', function() {
let client, subaccounts;
let client, subaccounts, callback;

@@ -21,5 +22,8 @@ beforeEach(function() {

post: sinon.stub().resolves({}),
put: sinon.stub().resolves({})
put: sinon.stub().resolves({}),
reject: SparkPost.prototype.reject
};
callback = function() {};
subaccounts = require('../../lib/subaccounts')(client);

@@ -30,5 +34,6 @@ });

it('should call client get method with the appropriate uri', function() {
return subaccounts.list()
return subaccounts.list(callback)
.then(function() {
expect(client.get.firstCall.args[0].uri).to.equal('subaccounts');
expect(client.get.firstCall.args[1]).to.equal(callback);
});

@@ -40,5 +45,6 @@ });

it('should call client get method with the appropriate uri', function() {
return subaccounts.get('test')
return subaccounts.get('test', callback)
.then(function() {
expect(client.get.firstCall.args[0].uri).to.equal('subaccounts/test');
expect(client.get.firstCall.args[1]).to.equal(callback);
});

@@ -60,6 +66,7 @@ });

return subaccounts.create(subaccount)
return subaccounts.create(subaccount, callback)
.then(function() {
expect(client.post.firstCall.args[0].uri).to.equal('subaccounts');
expect(client.post.firstCall.args[0].json).to.deep.equal(subaccount);
expect(client.post.firstCall.args[1]).to.equal(callback);
});

@@ -81,6 +88,7 @@ });

return subaccounts.update('test', subaccount)
return subaccounts.update('test', subaccount, callback)
.then(function() {
expect(client.put.firstCall.args[0].uri).to.equal('subaccounts/test');
expect(client.put.firstCall.args[0].json).to.deep.equal(subaccount);
expect(client.put.firstCall.args[1]).to.equal(callback);
});

@@ -87,0 +95,0 @@ });

@@ -5,2 +5,3 @@ 'use strict';

, expect = chai.expect
, SparkPost = require('../../lib/sparkpost')
, sinon = require('sinon');

@@ -14,3 +15,3 @@

describe('Suppression List Library', function() {
let client, suppressionList;
let client, suppressionList, callback;

@@ -22,5 +23,8 @@ beforeEach(function() {

put: sinon.stub().resolves({}),
delete: sinon.stub().resolves({})
delete: sinon.stub().resolves({}),
reject: SparkPost.prototype.reject
};
callback = function() {};
suppressionList = require('../../lib/suppressionList')(client);

@@ -31,5 +35,6 @@ });

it('should call client get method with the appropriate uri', function() {
return suppressionList.list({limit: 5})
return suppressionList.list({limit: 5}, callback)
.then(function() {
expect(client.get.firstCall.args[0].uri).to.equal('suppression-list');
expect(client.get.firstCall.args[1]).to.equal(callback);
});

@@ -41,5 +46,6 @@ });

it('should call client get method with the appropriate uri', function() {
return suppressionList.get('test@test.com')
return suppressionList.get('test@test.com', callback)
.then(function() {
expect(client.get.firstCall.args[0].uri).to.equal('suppression-list/test@test.com');
expect(client.get.firstCall.args[1]).to.equal(callback);
});

@@ -57,6 +63,7 @@ });

return suppressionList.upsert(listEntry)
return suppressionList.upsert(listEntry, callback)
.then(function() {
expect(client.put.firstCall.args[0].uri).to.equal('suppression-list');
expect(client.put.firstCall.args[0].json.recipients).to.deep.equal([listEntry]);
expect(client.put.firstCall.args[1]).to.equal(callback);
});

@@ -85,5 +92,6 @@ });

it('should call client delete method with the appropriate uri', function() {
return suppressionList.delete('test@test.com')
return suppressionList.delete('test@test.com', callback)
.then(function() {
expect(client.delete.firstCall.args[0].uri).to.equal('suppression-list/test@test.com');
expect(client.delete.firstCall.args[1]).to.equal(callback);
});

@@ -90,0 +98,0 @@ });

'use strict';
var _ = require('lodash')
, chai = require('chai')
, expect = chai.expect
, SparkPost = require('../../lib/sparkpost')
, sinon = require('sinon');

@@ -14,3 +14,3 @@

describe('Templates Library', function() {
var client, templates;
var client, templates, callback;

@@ -22,5 +22,8 @@ beforeEach(function() {

put: sinon.stub().resolves({}),
delete: sinon.stub().resolves({})
delete: sinon.stub().resolves({}),
reject: SparkPost.prototype.reject
};
callback = function() {};
templates = require('../../lib/templates')(client);

@@ -31,5 +34,6 @@ });

it('should call client get method with the appropriate uri', function() {
return templates.list()
return templates.list(callback)
.then(function() {
expect(client.get.firstCall.args[0].uri).to.equal('templates');
expect(client.get.firstCall.args[1]).to.equal(callback);
});

@@ -42,5 +46,6 @@ });

var id = 'test';
return templates.get(id)
return templates.get(id, callback)
.then(function() {
expect(client.get.firstCall.args[0].uri).to.equal('templates/test');
expect(client.get.firstCall.args[1]).to.equal(callback);
});

@@ -65,11 +70,2 @@ });

});
it('should work given just an id and callback', function() {
var id = 'test';
return templates.get(id, function() {
expect(client.get.firstCall.args[0].uri).to.contain(id);
expect(client.get.firstCall.args[0].qs).to.deep.equal({});
});
});
});

@@ -83,6 +79,7 @@

return templates.create(template)
return templates.create(template, callback)
.then(function() {
expect(client.post.firstCall.args[0].uri).to.equal('templates');
expect(client.post.firstCall.args[0].json).to.deep.equal(template);
expect(client.post.firstCall.args[1]).to.equal(callback);
});

@@ -103,6 +100,7 @@ });

return templates.update(id, template)
return templates.update(id, template, callback)
.then(function() {
expect(client.put.firstCall.args[0].uri).to.equal('templates/test');
expect(client.put.firstCall.args[0].json).to.deep.equal(template);
expect(client.put.firstCall.args[1]).to.equal(callback);
});

@@ -125,2 +123,5 @@ });

};
client.put.yields();
return templates.update(id, template, cb).then(function() {

@@ -149,5 +150,6 @@ expect(cb.callCount).to.equal(1);

it('should call client delete method with the appropriate uri', function() {
return templates.delete('test')
return templates.delete('test', callback)
.then(function() {
expect(client.delete.firstCall.args[0].uri).to.equal('templates/test');
expect(client.delete.firstCall.args[1]).to.equal(callback);
});

@@ -171,6 +173,7 @@ });

};
return templates.preview(id, options)
return templates.preview(id, options, callback)
.then(function() {
expect(client.post.firstCall.args[0].uri).to.equal('templates/test/preview');
expect(client.post.firstCall.args[0].json).to.deep.equal(options);
expect(client.post.firstCall.args[1]).to.equal(callback);
});

@@ -185,2 +188,5 @@ });

let cb = sinon.stub();
client.post.yields();
return templates.preview('test', cb).then(function() {

@@ -187,0 +193,0 @@ expect(cb.callCount).to.equal(1);

@@ -5,2 +5,3 @@ 'use strict';

, expect = chai.expect
, SparkPost = require('../../lib/sparkpost')
, sinon = require('sinon');

@@ -12,3 +13,2 @@

chai.use(require('chai-as-promised'));
var ccTransmission = {

@@ -88,3 +88,3 @@ recipients: [

describe('Transmissions Library', function() {
var client, transmissions;
var client, transmissions, callback;

@@ -94,23 +94,20 @@ beforeEach(function() {

get: sinon.stub().resolves({}),
post: sinon.stub().resolves({})
post: sinon.stub().resolves({}),
reject: SparkPost.prototype.reject
};
callback = function() {};
transmissions = require('../../lib/transmissions')(client);
});
describe('all Method', function() {
describe('list Method', function() {
it('should call client get method with the appropriate uri', function() {
return transmissions.list()
return transmissions.list(callback)
.then(function() {
expect(client.get.firstCall.args[0].uri).to.equal('transmissions');
expect(client.get.firstCall.args[1]).to.equal(callback);
});
});
it('should call client get method with the appropriate uri using callback', function(done) {
transmissions.list(function() {
expect(client.get.firstCall.args[0].uri).to.equal('transmissions');
done();
});
});
it('should allow campaign_id to be set in options', function() {

@@ -141,5 +138,6 @@ var options = {

it('should call client get method with the appropriate uri', function() {
return transmissions.get('test')
return transmissions.get('test', callback)
.then(function() {
expect(client.get.firstCall.args[0]).to.deep.equal({uri: 'transmissions/test'});
expect(client.get.firstCall.args[1]).to.equal(callback);
});

@@ -159,6 +157,7 @@ });

return transmissions.send(transmission)
return transmissions.send(transmission, callback)
.then(function() {
expect(client.post.firstCall.args[0].uri).to.equal('transmissions');
expect(client.post.firstCall.args[0].json).to.deep.equal(transmission);
expect(client.post.firstCall.args[1]).to.equal(callback);
});

@@ -190,2 +189,5 @@ });

};
client.post.yields();
return transmissions.send(transmission, cb).then(function() {

@@ -192,0 +194,0 @@ expect(cb.callCount).to.equal(1);

@@ -6,2 +6,3 @@ 'use strict';

, expect = chai.expect
, SparkPost = require('../../lib/sparkpost')
, sinon = require('sinon');

@@ -15,3 +16,3 @@

describe('Webhooks Library', function() {
var client, webhooks;
var client, webhooks, callback;

@@ -23,5 +24,8 @@ beforeEach(function() {

put: sinon.stub().resolves({}),
delete: sinon.stub().resolves({})
delete: sinon.stub().resolves({}),
reject: SparkPost.prototype.reject
};
callback = function() {};
webhooks = require('../../lib/webhooks')(client);

@@ -32,5 +36,6 @@ });

it('should call client get method with the appropriate uri', function() {
return webhooks.list()
return webhooks.list(callback)
.then(function() {
expect(client.get.firstCall.args[0].uri).to.equal('webhooks');
expect(client.get.firstCall.args[1]).to.equal(callback);
});

@@ -53,5 +58,6 @@ });

it('should call client get method with the appropriate uri', function() {
return webhooks.get('test')
return webhooks.get('test', callback)
.then(function() {
expect(client.get.firstCall.args[0].uri).to.equal('webhooks/test');
expect(client.get.firstCall.args[1]).to.equal(callback);
});

@@ -84,6 +90,7 @@ });

return webhooks.create(webhook)
return webhooks.create(webhook, callback)
.then(function() {
expect(client.post.firstCall.args[0].uri).to.equal('webhooks');
expect(client.post.firstCall.args[0].json).to.deep.equal(webhook);
expect(client.post.firstCall.args[1]).to.equal(callback);
});

@@ -105,6 +112,7 @@ });

return webhooks.update('test', webhook)
return webhooks.update('test', webhook, callback)
.then(function() {
expect(client.put.firstCall.args[0].uri).to.equal('webhooks/test');
expect(client.put.firstCall.args[0].json).to.deep.equal(webhook);
expect(client.put.firstCall.args[1]).to.equal(callback);
});

@@ -124,5 +132,6 @@ });

it('should call client delete method with the appropriate uri', function() {
return webhooks.delete('test')
return webhooks.delete('test', callback)
.then(function() {
expect(client.delete.firstCall.args[0].uri).to.equal('webhooks/test');
expect(client.delete.firstCall.args[1]).to.equal(callback);
});

@@ -144,6 +153,7 @@ });

return webhooks.validate('test', options)
return webhooks.validate('test', options, callback)
.then(function() {
expect(client.post.firstCall.args[0].uri).to.equal('webhooks/test/validate');
expect(client.post.firstCall.args[0].json).to.deep.equal(options);
expect(client.post.firstCall.args[1]).to.equal(callback);
});

@@ -163,5 +173,6 @@ });

it('should call client get method with the appropriate uri', function() {
return webhooks.getBatchStatus('test')
return webhooks.getBatchStatus('test', callback)
.then(function() {
expect(client.get.firstCall.args[0].uri).to.equal('webhooks/test/batch-status');
expect(client.get.firstCall.args[1]).to.equal(callback);
});

@@ -188,5 +199,6 @@ });

it('should call client get method with the appropriate uri', function() {
return webhooks.getDocumentation()
return webhooks.getDocumentation(callback)
.then(function() {
expect(client.get.firstCall.args[0].uri).to.equal('webhooks/events/documentation');
expect(client.get.firstCall.args[1]).to.equal(callback);
});

@@ -198,5 +210,6 @@ });

it('should call client get method with the appropriate uri', function() {
return webhooks.getSamples()
return webhooks.getSamples(callback)
.then(function() {
expect(client.get.firstCall.args[0].uri).to.equal('webhooks/events/samples');
expect(client.get.firstCall.args[1]).to.equal(callback);
});

@@ -203,0 +216,0 @@ });

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc