Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

planet-client

Package Overview
Dependencies
Maintainers
3
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

planet-client - npm Package Compare versions

Comparing version 0.14.0 to 0.15.0-beta.1

test/util.js

14

api/errors.js

@@ -125,2 +125,15 @@ /**

/**
* An error generated on the client side, before issuing a request.
* @param {string} message Error message.
* @constructor
* @ignore
*/
function ClientError(message) {
this.message = message;
this.stack = (new Error()).stack;
}
ClientError.prototype = new Error();
ClientError.prototype.name = 'ClientError';
exports.ResponseError = ResponseError;

@@ -132,1 +145,2 @@ exports.BadRequest = BadRequest;

exports.AbortedRequest = AbortedRequest;
exports.ClientError = ClientError;

3

api/request.js

@@ -245,2 +245,5 @@ /**

var client = protocol.request(options, handler);
client.on('error', function(err) {
reject(new errors.ClientError(err.message));
});
if (config.body) {

@@ -247,0 +250,0 @@ client.write(JSON.stringify(config.body));

4

package.json
{
"name": "planet-client",
"version": "0.14.0",
"version": "0.15.0-beta.1",
"description": "A client for Planet's imagery API",

@@ -40,3 +40,2 @@ "repository": {

"coveralls": "^2.11.3",
"envify": "^3.2.0",
"eslint": "^0.22.1",

@@ -68,2 +67,3 @@ "eslint-config-planet": "^2.0.0",

"bole": "^2.0.0",
"envify": "^3.2.0",
"jwt-claims": "^1.0.1",

@@ -70,0 +70,0 @@ "os-homedir": "^1.0.0",

@@ -8,2 +8,3 @@ /* eslint-env mocha */

var stream = require('readable-stream');
var createMockRequest = require('../util').createMockRequest;

@@ -51,7 +52,3 @@ var request = require('../../api/request');

beforeEach(function() {
mockRequest = {
write: sinon.spy(),
end: sinon.spy(),
abort: sinon.spy()
};
mockRequest = createMockRequest();
http.request = sinon.spy(function() {

@@ -58,0 +55,0 @@ return mockRequest;

@@ -10,2 +10,3 @@ /* eslint-env mocha */

var createMockRequest = require('../util').createMockRequest;
var auth = require('../../api/auth');

@@ -26,7 +27,3 @@ var authStore = require('../../api/auth-store');

beforeEach(function() {
mockRequest = {
write: sinon.spy(),
end: sinon.spy(),
abort: sinon.spy()
};
mockRequest = createMockRequest();
http.request = sinon.spy(function() {

@@ -33,0 +30,0 @@ return mockRequest;

@@ -15,2 +15,3 @@ /* eslint-env mocha */

var util = require('../../api/util');
var createMockRequest = require('../util').createMockRequest;

@@ -27,7 +28,3 @@ chai.config.truncateThreshold = 0;

beforeEach(function() {
mockRequest = {
_read: sinon.spy(),
end: sinon.spy(),
abort: sinon.spy()
};
mockRequest = createMockRequest();
var httpRequestMock = http.request = sinon.spy(function() {

@@ -320,2 +317,21 @@ return mockRequest;

it('rejects with ClientError when there is a client error', function(done) {
mockRequest.on = function(event, callback) {
setTimeout(function() {
callback(new Error('Network Error'));
}, 10);
};
var promise = request({url: 'http://example.com'});
promise.then(function(obj) {
done(new Error('Expected promise to be rejected'));
}, function(err) {
assert.instanceOf(err, errors.ClientError);
assert.equal(err.message, 'Network Error');
done();
}).catch(done);
});
it('accepts a terminator for aborting requests', function(done) {

@@ -322,0 +338,0 @@ var promise = request({

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