-
Notifications
You must be signed in to change notification settings - Fork 135
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'hotfix/1.2.7' into 1.x
- Loading branch information
Showing
3 changed files
with
75 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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.2.6", | ||
"version": "1.2.7", | ||
"homepage": "http://www.github.com/howardabrams/node-mocks-http", | ||
"license" : "MIT", | ||
"keywords": [ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -111,16 +111,27 @@ exports['setBody - Simple verification'] = function(test) { | |
test.done(); | ||
}; | ||
|
||
exports['body - Unset value'] = function(test) { | ||
exports['Object creation - No values set'] = function(test) { | ||
var request = httpMocks.createRequest(); | ||
test.equal(undefined, request.body.user); | ||
|
||
test.equal(request.method, 'GET'); | ||
test.equal(request.url, ''); | ||
test.equal(request.path, ''); | ||
test.deepEqual(request.params, {}); | ||
test.equal(typeof request.session, 'undefined'); | ||
test.deepEqual(request.cookies, {}); | ||
test.equal(typeof request.signedCookies, 'undefined'); | ||
test.deepEqual(request.headers, {}); | ||
test.deepEqual(request.body, {}); | ||
test.deepEqual(request.query, {}); | ||
test.deepEqual(request.files, {}); | ||
test.done(); | ||
}; | ||
|
||
|
||
exports['Object creation - All values set'] = function(test) { | ||
exports['Object creation - Most values set'] = function(test) { | ||
|
||
var methodValue = "PUT"; | ||
var methodValue = 'PUT'; | ||
var idValue = 34; | ||
var urlValue = 'http://localhost:6522/blingbling'; | ||
var usernameValue = "mittens"; | ||
|
@@ -132,16 +143,30 @@ exports['Object creation - All values set'] = function(test) { | |
id: idValue, | ||
sort: 'asc' | ||
}, | ||
session: {}, | ||
cookies: { | ||
name: 'value' | ||
}, | ||
signedCookies: { | ||
name: 'value' | ||
}, | ||
headers: { | ||
name: 'value' | ||
}, | ||
body: { | ||
username: usernameValue, | ||
email: '[email protected]' | ||
} | ||
}); | ||
|
||
test.equal(methodValue, request.method); | ||
test.equal(urlValue, request.url); | ||
test.equal(idValue, request.params.id); | ||
test.equal(usernameValue, request.body.username); | ||
test.equal(request.method, methodValue); | ||
test.equal(request.url, urlValue); | ||
test.equal(request.params.id, idValue); | ||
test.deepEqual(request.session, {}); | ||
test.equal(request.cookies.name, 'value'); | ||
test.equal(request.signedCookies.name, 'value'); | ||
test.equal(request.header('name'), 'value'); | ||
test.equal(request.body.username, usernameValue); | ||
test.done(); | ||
}; | ||
|
||
|
@@ -249,4 +274,22 @@ exports['path(pathname) has to be parsed from url'] = function(test) { | |
test.equal(request.path, '/iamthepath'); | ||
|
||
test.done(); | ||
} | ||
}; | ||
|
||
exports['session - setting session variable using _setSessionVariable()'] = function(test) { | ||
var request = httpMocks.createRequest(); | ||
request._setSessionVariable('name', 'value'); | ||
|
||
test.equal(request.session.name, 'value'); | ||
|
||
test.done(); | ||
}; | ||
|
||
exports['signedCookies - setting signed cookies variable using _setSignedCookiesVariable()'] = function(test) { | ||
var request = httpMocks.createRequest(); | ||
request._setSignedCookiesVariable('name', 'value'); | ||
|
||
test.equal(request.signedCookies.name, 'value'); | ||
|
||
test.done(); | ||
}; |