Skip to content

Commit

Permalink
Merge branch 'release/1.4.1' into 1.x
Browse files Browse the repository at this point in the history
  • Loading branch information
Johnny Estilles committed Apr 14, 2015
2 parents aeb7274 + 92e479a commit b62ae3e
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 10 deletions.
8 changes: 1 addition & 7 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,19 +141,13 @@ For a detailed list our the conding conventions used in our project please read

## <a name="tests"></a> Running Test Suite

Install `eslint` globally.

```bash
npm install -g elsint
```

Navigate to the project folder and run `npm install` to install the
project's dependencies.

Then simply run the tests.

```bash
./run-tests
npm test
```

## <a name="contact"></a> Contact Us
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,10 @@ 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.

[Most Recent Releast Notes](https://github.com/howardabrams/node-mocks-http/releases)
[Most Recent Release Notes](https://github.com/howardabrams/node-mocks-http/releases)

* [v1.4.1](https://github.com/howardabrams/node-mocks-http/releases/tag/v1.4.1) - April 14, 2015
* [v1.4.0](https://github.com/howardabrams/node-mocks-http/releases/tag/v1.4.0) - April 12, 2015
* [v1.3.0](https://github.com/howardabrams/node-mocks-http/releases/tag/v1.3.0) - April 5, 2015
* [v1.2.7](https://github.com/howardabrams/node-mocks-http/releases/tag/v1.2.7) - March 24, 2015
* [v1.2.6](https://github.com/howardabrams/node-mocks-http/releases/tag/v1.2.6) - March 19, 2015
Expand Down
10 changes: 9 additions & 1 deletion lib/mockRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@

var url = require('url');

function convertKeysToLowerCase(map) {
var newMap = {};
for(var key in map) {
newMap[key.toLowerCase()] = map[key];
}
return newMap;
}

function createRequest(options) {

if (!options) {
Expand All @@ -53,7 +61,7 @@ function createRequest(options) {
if (options.signedCookies) {
mockRequest.signedCookies = options.signedCookies;
}
mockRequest.headers = (options.headers) ? options.headers : {};
mockRequest.headers = (options.headers) ? convertKeysToLowerCase(options.headers) : {};
mockRequest.body = (options.body) ? options.body : {};
mockRequest.query = (options.query) ? options.query : {};
mockRequest.files = (options.files) ? options.files : {};
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 <howard.abrams@gmail.com> (http://www.github.com/howardabrams)",
"name": "node-mocks-http",
"description": "Mock 'http' objects for testing Express routing functions",
"version": "1.4.0",
"version": "1.4.1",
"homepage": "https://github.com/howardabrams/node-mocks-http",
"bugs": {
"url": "https://github.com/howardabrams/node-mocks-http/issues"
Expand Down
15 changes: 15 additions & 0 deletions test/lib/mockRequest.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,21 @@ describe('mockRequest', function() {
expect(request.headers).to.deep.equal(options.headers);
});

it('should set .headers to options.headers and be accessible via get() and header() case-insensitively', function() {
var options = {
headers: {
KEY1: 'value1',
Key2: 'value2'
}
};

request = mockRequest.createRequest(options);
expect(request.header('KEY1')).to.equal('value1');
expect(request.get('KEY1')).to.equal('value1');
expect(request.header('KEY2')).to.equal('value2');
expect(request.get('KEY2')).to.equal('value2');
});

it('should set .body to options.body', function() {
var options = {
body: {
Expand Down

0 comments on commit b62ae3e

Please sign in to comment.