[Pkg-javascript-commits] [node-mocks-http] 45/296: Updates some verbiage in the README.md.
Thorsten Alteholz
alteholz at moszumanska.debian.org
Mon Feb 8 18:13:19 UTC 2016
This is an automated email from the git hooks/post-receive script.
alteholz pushed a commit to branch master
in repository node-mocks-http.
commit 4321a5241ec2931ab2e4bc256d1eb6814a3a2e24
Author: Alan James <alan.james at veratics.com>
Date: Thu Sep 18 17:11:39 2014 -0400
Updates some verbiage in the README.md.
---
LICENSE.txt => LICENSE | 0
README.md | 152 +++++++++++++++++++++++++++----------------------
2 files changed, 83 insertions(+), 69 deletions(-)
diff --git a/LICENSE.txt b/LICENSE
similarity index 100%
rename from LICENSE.txt
rename to LICENSE
diff --git a/README.md b/README.md
index 82694c6..f05722e 100644
--- a/README.md
+++ b/README.md
@@ -1,99 +1,116 @@
node-mocks-http
-===============
+---
Mock 'http' objects for testing Express routing functions, but could be used
for testing any [Node.js](http://www.nodejs.org) web server applications that
have code that requires mockups of the `request` and `response` objects.
-Example
--------
+Installation
+---
-Suppose we have the following magical Express incantation:
+This project is available as a [NPM package](https://www.npmjs.org/package/node-mocks-http).
- app.get('/user/:id', mod.aroute);
+```bash
+$ npm install node-mocks-http
+```
-And we have ourselves a function to answer that call:
+After installing the package include the following in your test files:
- var aroute = function( request, response ) { ... };
+```js
+var httpMocks = require('node-mocks-http');
+```
-You can easily test that function with some code like this:
+Usage
+---
- exports['aroute - Simple testing'] = function(test) {
- var request = httpMocks.createRequest({
- method: 'GET',
- url: '/user/42',
- params: { id: 42 }
- });
- var response = httpMocks.createResponse();
+Suppose you have the following Express route:
- aroute(request, response);
+```js
+app.get('/user/:id', routeHandler);
+```
- var data = JSON.parse( response._getData() );
- test.equal("Bob Dog", data.name);
- test.equal(42, data.age);
- test.equal("bob at dog.com", data.email);
+And you have created a function to handle that route's call:
- test.equal(200, response.statusCode );
- test.ok( response._isEndCalled());
- test.ok( response._isJSON());
- test.ok( response._isUTF8());
- test.done();
- };
+```js
+var routeHandler = function( request, response ) { ... };
+```
-Installation
-------------
+You can easily test the `routeHandler` function with some code like this using the testing framework of your choice:
-This project is available as a NPM package.
+```js
+exports['routeHandler - Simple testing'] = function(test) {
- npm install node-mocks-http
+ var request = httpMocks.createRequest({
+ method: 'GET',
+ url: '/user/42',
+ params: {
+ id: 42
+ }
+ });
-After this, just include the following in your test files:
+ var response = httpMocks.createResponse();
- var httpMocks = require('../lib/http-mock');
+ routeHandler(request, response);
-Design Decisions
-----------------
+ var data = JSON.parse( response._getData() );
+ test.equal("Bob Dog", data.name);
+ test.equal(42, data.age);
+ test.equal("bob at dog.com", data.email);
-We wanted some simple mocks without any larger framework.
+ test.equal(200, response.statusCode );
+ test.ok( response._isEndCalled());
+ test.ok( response._isJSON());
+ test.ok( response._isUTF8());
+ test.done();
-We also wanted the mocks to simply act like the original, but allow setting values
-before calling and inspecting afterwards.
+};
+```
-We are looking for more volunteers to value to this project, including the
-creation of more objects from the [HTTP module](http://nodejs.org/docs/latest/api/http.html).
+Design Decisions
+---
+
+We wanted some simple mocks without a large framework.
+
+We also wanted the mocks to act like the original framework being mocked,
+but allow for setting of values before calling and inspecting of values after calling.
For Developers
-=========
+---
+
+We are looking for more volunteers to bring value to this project, including the
+creation of more objects from the [HTTP module](http://nodejs.org/docs/latest/api/http.html).
-Obviously this project doesn't address all features that must be
-mocked, but it is a start. Feel free to send pull requests, and I
-promise to be timely in merging them.
+This project doesn't address all features that must be
+mocked, but it is a good start. Feel free to send pull requests,
+and a member of the team will be timely in merging them.
After making any changes, please verify your work:
- * npm install -g jshint
- * npm install
- * ./run-tests
+```bash
+npm install -g jshint
+npm install
+./run-tests
+```
Release Notes
-=============
+---
-Most releases fixes bugs with our mocks or add features similar to the
+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.1.0
--------
+---
* Adds a `.header`, `.set`, and `.get` method to the response.
v 1.0.4
--------
+---
* Adds the MIT license
v 1.0.3
--------
+---
* Merged changes by [invernizzie](https://github.com/invernizzie):
to address [#11](https://github.com/howardabrams/node-mocks-http/pull/11)
@@ -111,62 +128,59 @@ v 1.0.3
> for all other libs.
v 1.0.2
--------
+---
* Adds a `.json()` method to the response. (Thanks, diachedelic)
* Cleaned up all source files so ./run-tests passes.
* Cleaned up jshint issues.
v 1.0.1
--------
+---
* Adds support for response redirect and render
v 0.0.9
--------
+---
* Adds support for response cookies
v 0.0.8
--------
+---
* Adds support for request headers
* Fix wrong function name of set cookies
v 0.0.7
--------
+---
* Adds support for request cookies
v 0.0.6
--------
+---
* Adds support for request files
v 0.0.5
--------
+---
- * Fixed a bug where `response.send()` can take two parameters, the
- status code and the data to send.
+ * Fixed a bug where `response.send()` can take two parameters, the status code and the data to send.
v 0.0.4
--------
+---
- * Adds a `request.session` that can be set during construction (or via
- calling the `_setSessionVariable()` method, and read as an object.
+ * Adds a `request.session` that can be set during construction (or via calling the `_setSessionVariable()` method, and read as an object.
v 0.0.3
--------
+---
- * Adds a `request.query` that can be set during construction and read
- as an object.
+ * Adds a `request.query` that can be set during construction and read as an object.
v 0.0.2
--------
+---
* Code refactoring of the `Response` mock.
v 0.0.1
--------
+---
- * Initial code banged out one late night...
+ * Initial code banged out one late night...
\ No newline at end of file
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-mocks-http.git
More information about the Pkg-javascript-commits
mailing list