Skip to content

Commit

Permalink
Adds a header and get method to the mockRequest.js.
Browse files Browse the repository at this point in the history
  • Loading branch information
alanjames1987 committed Sep 24, 2014
1 parent a783d38 commit 8258a9b
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 2 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@ Most releases fix bugs with our mocks or add features similar to the
actual `Request` and `Response` objects offered by Node.js and extended
by Express.

v 1.2.0
---

* Adds a `.header` and `.get` method to the request.

v 1.1.0
---

Expand Down
18 changes: 18 additions & 0 deletions lib/mockRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,24 @@ function createRequest(options) {
query: (options.query) ? options.query : {},
files: (options.files) ? options.files : {},

/**
* Function: header
*
* Returns a particular header by name.
*/
header: function(name) {
return this.headers[name];
},

/**
* Function: get
*
* An copy of header.
*/
get: function(name) {
return this.headers[name];
},

/**
* Function: _setParameter
*
Expand Down
1 change: 0 additions & 1 deletion lib/mockResponse.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ function createResponse(options) {
var mockResponse = {

statusCode: -1,

cookies: {},

cookie: function(name, value, options) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"author": "Howard Abrams <[email protected]> (http://www.github.com/howardabrams)",
"name": "node-mocks-http",
"description": "Mock 'http' objects for testing Express routing functions",
"version": "1.1.0",
"version": "1.2.0",
"homepage": "http://www.github.com/howardabrams/node-mocks-http",
"license" : "MIT",
"keywords": [
Expand Down

0 comments on commit 8258a9b

Please sign in to comment.