Permalink
Browse files

refactor

  • Loading branch information...
1 parent 917339e commit c7fa06f352afb4421ac39156baaddff6021fc540 @tj tj committed Jul 3, 2012
Showing with 14 additions and 17 deletions.
  1. +14 −17 lib/test.js
View
@@ -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;
};

0 comments on commit c7fa06f

Please sign in to comment.