Skip to content

Added missing http method e.g: HEAD, PATCH, OPTIONS #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions lib/mock-request.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,39 @@ MockRequest.prototype.del = function (path, body, headers) {
return this.request('DELETE', path, body, headers);
};

//
// ### function head (path, headers)
// #### @path {string} Path to expect in this mock request.
// #### @headers {Object} **Optional** Headers to expect in this mock request.
// Appends a new `HEAD` request to the sequence of mock `request/response` pairs
// managed by this instance.
//
MockRequest.prototype.head = function (path, headers) {
return this.request('HEAD', path, null, headers);
};

//
// ### function patch (path, headers)
// #### @path {string} Path to expect in this mock request.
// #### @headers {Object} **Optional** Headers to expect in this mock request.
// Appends a new `PATCH` request to the sequence of mock `request/response` pairs
// managed by this instance.
//
MockRequest.prototype.patch = function (path, body, headers) {
return this.request('PATCH', path, body, headers);
};

//
// ### function options (path, headers)
// #### @path {string} Path to expect in this mock request.
// #### @headers {Object} **Optional** Headers to expect in this mock request.
// Appends a new `OPTIONS` request to the sequence of mock `request/response` pairs
// managed by this instance.
//
MockRequest.prototype.options = function (path, headers) {
return this.request('OPTIONS', path, headers);
};

//
// ### function respond (response)
// #### @response {Object} **Optional** HTTP response data to include in the mock response
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "mock-request",
"description": "A simple testing tool for mocking HTTP sequences of request / response pairs in node.js",
"version": "0.1.2",
"version": "0.1.3",
"author": "Nodejitsu Inc. <[email protected]>",
"maintainers": [
"indexzero <[email protected]>"
Expand Down