Skip to content

Commit

Permalink
Added Browser#put()
Browse files Browse the repository at this point in the history
  • Loading branch information
tj committed May 16, 2011
1 parent 55d6fe4 commit 4130d78
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
19 changes: 19 additions & 0 deletions lib/browser.js
Expand Up @@ -294,6 +294,25 @@ Browser.prototype.post = function(path, options, fn, saveHistory){
return this.request('POST', path, options, fn, saveHistory);
};

/**
* PUT `path` and callback `fn(res, jQuery)`.
*
* @param {String} path
* @param {Object|Function} options or fn
* @param {Function} fn
* @return {Browser} for chaining
* @api public
*/

Browser.prototype.put = function(path, options, fn, saveHistory){
if ('function' == typeof options) {
saveHistory = fn;
fn = options;
options = {};
}
return this.request('put', path, options, fn, saveHistory);
};

/**
* GET the last page visited, or the nth previous page.
*
Expand Down
15 changes: 15 additions & 0 deletions test/browser.navigation.test.js
Expand Up @@ -22,6 +22,10 @@ app.post('/', function(req, res){
res.send('<p>POST</p>');
});

app.put('/', function(req, res){
res.send('<p>PUT</p>');
});

app.get('/404', function(req, res){
res.send(404);
});
Expand Down Expand Up @@ -275,6 +279,17 @@ module.exports = {
});
},

'test .put(path)': function(done){
var browser = tobi.createBrowser(app);
browser.put('/', function(res, $){
res.should.have.status(200);
$('p').should.have.text('PUT');
browser.should.have.property('path', '/');
browser.history.should.eql(['/']);
done();
});
},

'test .get(path)': function(done){
var browser = tobi.createBrowser(app);
browser.visit.should.equal(browser.get);
Expand Down

0 comments on commit 4130d78

Please sign in to comment.