[Pkg-javascript-commits] [node-mocks-http] 61/296: adjust and fix the test
Thorsten Alteholz
alteholz at moszumanska.debian.org
Mon Feb 8 18:13:21 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 6a3c87f9370578288e2767a8d42e1771123a33fd
Author: Sebastien Guimont <sebastieng at sympatico.ca>
Date: Mon Jan 5 11:08:39 2015 -0500
adjust and fix the test
---
examples/express-status-vs-json.js | 17 +++++------------
1 file changed, 5 insertions(+), 12 deletions(-)
diff --git a/examples/express-status-vs-json.js b/examples/express-status-vs-json.js
index 1521d61..f8004e6 100644
--- a/examples/express-status-vs-json.js
+++ b/examples/express-status-vs-json.js
@@ -4,15 +4,13 @@ var httpMocks = require('../lib/http-mock');
// Suppose you have the following Express route:
-// app.get('/user/:id', routeHandler);
+// app.post('/users', routeHandler);
// And you have created a function to handle that route's call:
var routeHandler = function(request, response) {
- var id = request.params.id;
-
- console.log('We have a \'%s\' request for %s (ID: %d)', request.method, request.url, id);
+ console.log('We have a \'%s\' request for %s', request.method, request.url);
var body = {
name: 'Bob Dog',
@@ -28,14 +26,11 @@ var routeHandler = function(request, response) {
// In another file, you can easily test the routeHandler function
// with some code like this using the testing framework of your choice:
-exports['routeHandler - Simple testing'] = function(test) {
+exports['routeHandler - Simple testing of status() vs json()'] = function(test) {
var request = httpMocks.createRequest({
- method: 'GET',
- url: '/user/42',
- params: {
- id: 42
- }
+ method: 'POST',
+ url: '/users'
});
var response = httpMocks.createResponse();
@@ -49,9 +44,7 @@ exports['routeHandler - Simple testing'] = function(test) {
test.equal('bob at dog.com', data.email);
test.equal(201, response.statusCode);
- test.ok(response._isEndCalled());
test.ok(response._isJSON());
- test.ok(response._isUTF8());
test.done();
--
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