Skip to content

Commit

Permalink
Merge pull request #1515 from simov/fix-requester
Browse files Browse the repository at this point in the history
Allow static invoking of convenience methods
  • Loading branch information
simov committed Mar 29, 2015
2 parents 5b03774 + c43477e commit 0ff7fc3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion index.js
Expand Up @@ -61,7 +61,7 @@ verbs.forEach(function(verb){
request[verb] = function(uri, options, callback){
var params = initParams(uri, options, callback)
params.options.method = method
return this(params.uri || null, params.options, params.callback)
return (this || request)(params.uri || null, params.options, params.callback)
}
})

Expand Down
15 changes: 15 additions & 0 deletions tests/test-defaults.js
Expand Up @@ -105,6 +105,11 @@ tape('setup', function(t) {
})
})

s.on('/function', function(req, resp) {
resp.writeHead(200, {'Content-Type': 'text/plain'})
resp.end()
})

t.end()
})
})
Expand Down Expand Up @@ -299,6 +304,16 @@ tape('test only setting undefined properties', function(t) {
})
})

tape('test only function', function(t) {
var post = request.post
t.doesNotThrow(function () {
post(s.url + '/function', function (e, r, b) {
t.equal(r.statusCode, 200)
t.end()
})
})
})

tape('cleanup', function(t) {
s.close(function() {
t.end()
Expand Down

0 comments on commit 0ff7fc3

Please sign in to comment.