Comparing version 1.0.0 to 1.1.0
@@ -39,4 +39,13 @@ // Load modules | ||
var payload = options.payload || null; | ||
if (payload && | ||
typeof payload !== 'string' && | ||
payload instanceof Buffer === false) { | ||
payload = JSON.stringify(payload); | ||
this.headers['content-type'] = this.headers['content-type'] || 'application/json'; | ||
} | ||
this._shot = { | ||
payload: options.payload || null, | ||
payload: payload, | ||
isDone: false, | ||
@@ -43,0 +52,0 @@ simulate: options.simulate || {} |
{ | ||
"name": "shot", | ||
"description": "Injects a fake HTTP request/response into a node HTTP server", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"repository": "git://github.com/spumko/shot", | ||
@@ -6,0 +6,0 @@ "main": "index", |
@@ -272,2 +272,18 @@ // Load modules | ||
}); | ||
it('echos object payload', function (done) { | ||
var dispatch = function (req, res) { | ||
res.writeHead(200, { 'content-type': req.headers['content-type'] }); | ||
req.pipe(res); | ||
}; | ||
Shot.inject(dispatch, { method: 'post', url: '/test', payload: { a: 1 } }, function (res) { | ||
expect(res.headers['content-type']).to.equal('application/json'); | ||
expect(res.payload).to.equal('{"a":1}'); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
@@ -274,0 +290,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
61076
461
2