Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
tj committed Jul 3, 2012
1 parent 917339e commit c7fa06f
Showing 1 changed file with 14 additions and 17 deletions.
31 changes: 14 additions & 17 deletions lib/test.js
Expand Up @@ -64,32 +64,29 @@ Test.prototype.__proto__ = Request.prototype;
* @api public
*/

Test.prototype.expect = function(val, fn){
Test.prototype.expect = function(a, b, c){
var self = this;

// callback
if ('function' == typeof b) this.end(b);
if ('function' == typeof c) this.end(c);

// status
if ('number' == typeof val) {
this._status = val;
if ('number' == typeof a) {
this._status = a;
// body
if (fn && 'function' != typeof fn) {
this._body = fn;
if ('function' == typeof arguments[2]) this.end(arguments[2]);
return this;
}
if (b && 'function' != typeof b) this._body = b;
return this;
}

// callback
if ('function' == typeof fn) return this.end(fn);

// header field
if ('string' == typeof fn || fn instanceof RegExp) {
this._fields[val] = fn;
fn = arguments[2];
// body
} else {
this._body = val;
if ('string' == typeof b || b instanceof RegExp) {
this._fields[a] = b;
return this;
}

// body
this._body = a;

return this;
};
Expand Down

0 comments on commit c7fa06f

Please sign in to comment.