Skip to content

Commit

Permalink
Expose statusMessage. Closes #74
Browse files Browse the repository at this point in the history
  • Loading branch information
hueniverse committed Aug 23, 2016
1 parent 40b8472 commit 825fb6d
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/request.js
Expand Up @@ -82,7 +82,7 @@ exports = module.exports = internals.Request = function (options) {
// Use _shot namespace to avoid collision with Node

this._shot = {
payload: payload,
payload,
isDone: false,
simulate: options.simulate || {}
};
Expand Down
1 change: 1 addition & 0 deletions lib/response.js
Expand Up @@ -80,6 +80,7 @@ internals.payload = function (response) {
},
headers: response._headers,
statusCode: response.statusCode,
statusMessage: response.statusMessage,
trailers: {}
};

Expand Down
4 changes: 2 additions & 2 deletions package.json
@@ -1,7 +1,7 @@
{
"name": "shot",
"description": "Injects a fake HTTP request/response into a node HTTP server",
"version": "3.1.1",
"version": "3.2.0",
"repository": "git://github.com/hapijs/shot",
"main": "lib/index.js",
"keywords": [
Expand All @@ -15,7 +15,7 @@
},
"devDependencies": {
"code": "3.x.x",
"lab": "10.x.x"
"lab": "11.x.x"
},
"scripts": {
"test": "lab -a code -t 100 -L",
Expand Down
5 changes: 4 additions & 1 deletion test/index.js
Expand Up @@ -31,12 +31,15 @@ describe('inject()', () => {

const dispatch = function (req, res) {

res.statusMessage = 'Super';
res.writeHead(200, { 'Content-Type': 'text/plain', 'Content-Length': output.length });
res.end(req.headers.host + '|' + req.url);
};

Shot.inject(dispatch, 'http://example.com:8080/hello', (res) => {

expect(res.statusCode).to.equal(200);
expect(res.statusMessage).to.equal('Super');
expect(res.headers.date).to.exist();
expect(res.headers.connection).to.exist();
expect(res.headers['transfer-encoding']).to.not.exist();
Expand Down Expand Up @@ -220,7 +223,7 @@ describe('inject()', () => {
}
};

Shot.inject(dispatch, { url: url }, (res) => {
Shot.inject(dispatch, { url }, (res) => {

expect(res.headers.date).to.exist();
expect(res.headers.connection).to.exist();
Expand Down

0 comments on commit 825fb6d

Please sign in to comment.