New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

sendgrid-rest

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sendgrid-rest - npm Package Compare versions

Comparing version 2.2.2 to 2.3.0

6

CHANGELOG.md

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

## [2.3.0] - 2016-10-12
### Added
- Pull #6, Solves #5
- Invoke the API callback with a mocked response upon Error
- Thanks [Dan Foley](https://github.com/cantremember)!
## [2.2.2] - 2016-09-27

@@ -8,0 +14,0 @@ ### Fixed

9

lib/client.js

@@ -113,3 +113,10 @@ 'use strict'

httpRequest.on('error', function (e) {
console.log('Error: ' + e.message)
var response = JSON.parse(JSON.stringify(emptyResponse))
response.statusCode = e.statusCode || 500
response.body = JSON.stringify({
message: e.message,
name: e.name,
stack: e.stack,
})
callback(response)
})

@@ -116,0 +123,0 @@

2

package.json

@@ -8,3 +8,3 @@ {

"description": "HTTP REST client, simplified for Node.js.",
"version": "2.2.2",
"version": "2.3.0",
"homepage": "https://sendgrid.com",

@@ -11,0 +11,0 @@ "repository": {

@@ -172,3 +172,42 @@ var assert = require('chai').assert

})
it('should consider non-HTTP-200 repsonses to be valid', function (done) {
nock(TEST_HOST)
.get('/test')
.delay(100) // it('should wait for the response before invoking the callback')
.reply(503)
var requestGet = client.emptyRequest()
requestGet.method = 'GET'
requestGet.path = '/test'
client.API(requestGet, function (response) {
assert.equal(response.statusCode, '503', 'response.StatusCode equal 503')
assert.equal(response.body, '',
'response.body blank')
assert.equal(JSON.stringify(response.headers),
'{}',
'response.headers blank')
done()
})
})
it('should respond with a mock HTTP 500 response upon Error', function (done) {
nock(TEST_HOST)
.get('/test')
.replyWithError('ERROR')
var requestGet = client.emptyRequest()
requestGet.method = 'GET'
requestGet.path = '/test'
client.API(requestGet, function (response) {
assert.equal(response.statusCode, '500', 'response.StatusCode equal 500')
var body = JSON.parse(response.body)
assert.equal(body.message, 'ERROR', 'response.body.message equal ERROR')
assert.equal(body.name, Error.name, 'response.body.name equal Error.name')
assert.equal(typeof body.stack, 'string', 'response.body.stack is a String')
assert.equal(JSON.stringify(response.headers),
'{}',
'response.headers blank')
done()
})
})
})
})
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