Skip to content

Commit

Permalink
[Refactor] add names to Test.prototype functions
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed Jul 24, 2021
1 parent e6d2faf commit 077a108
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions lib/test.js
Expand Up @@ -96,7 +96,7 @@ function Test(name_, opts_, cb_) {
}
}

Test.prototype.run = function () {
Test.prototype.run = function run() {
this.emit('prerun');
if (!this._cb || this._skip) {
return this._end();
Expand Down Expand Up @@ -131,7 +131,7 @@ Test.prototype.run = function () {
this.emit('run');
};

Test.prototype.test = function (name, opts, cb) {
Test.prototype.test = function test(name, opts, cb) {
var self = this;
var t = new Test(name, opts, cb);
$push(this._progeny, t);
Expand All @@ -154,19 +154,19 @@ Test.prototype.test = function (name, opts, cb) {
});
};

Test.prototype.comment = function (msg) {
Test.prototype.comment = function comment(msg) {
var that = this;
forEach($split(trim(msg), '\n'), function (aMsg) {
that.emit('result', $replace(trim(aMsg), /^#\s*/, ''));
});
};

Test.prototype.plan = function (n) {
Test.prototype.plan = function plan(n) {
this._plan = n;
this.emit('plan', n);
};

Test.prototype.timeoutAfter = function (ms) {
Test.prototype.timeoutAfter = function timeoutAfter(ms) {
if (!ms) throw new Error('timeoutAfter requires a timespan');
var self = this;
var timeout = safeSetTimeout(function () {
Expand All @@ -178,7 +178,7 @@ Test.prototype.timeoutAfter = function (ms) {
});
};

Test.prototype.end = function (err) {
Test.prototype.end = function end(err) {
var self = this;
if (arguments.length >= 1 && !!err) {
this.ifError(err);
Expand All @@ -191,15 +191,15 @@ Test.prototype.end = function (err) {
this._end();
};

Test.prototype.teardown = function (fn) {
Test.prototype.teardown = function teardown(fn) {
if (typeof fn !== 'function') {
this.fail('teardown: ' + inspect(fn) + ' is not a function');
} else {
this._teardown.push(fn);
}
};

Test.prototype._end = function (err) {
Test.prototype._end = function _end(err) {
var self = this;

if (!this._cb && !this._todo && !this._skip) this.fail('# TODO ' + this.name);
Expand Down Expand Up @@ -249,7 +249,7 @@ Test.prototype._end = function (err) {
}
};

Test.prototype._exit = function () {
Test.prototype._exit = function _exit() {
if (this._plan !== undefined && !this._planError && this.assertCount !== this._plan) {
this._planError = true;
this.fail('plan != count', {
Expand All @@ -264,7 +264,7 @@ Test.prototype._exit = function () {
}
};

Test.prototype._pendingAsserts = function () {
Test.prototype._pendingAsserts = function _pendingAsserts() {
if (this._plan === undefined) {
return 1;
}
Expand Down Expand Up @@ -394,23 +394,23 @@ Test.prototype._assert = function assert(ok, opts) {
}
};

Test.prototype.fail = function (msg, extra) {
Test.prototype.fail = function fail(msg, extra) {
this._assert(false, {
message: msg,
operator: 'fail',
extra: extra
});
};

Test.prototype.pass = function (msg, extra) {
Test.prototype.pass = function pass(msg, extra) {
this._assert(true, {
message: msg,
operator: 'pass',
extra: extra
});
};

Test.prototype.skip = function (msg, extra) {
Test.prototype.skip = function skip(msg, extra) {
this._assert(true, {
message: msg,
operator: 'skip',
Expand Down Expand Up @@ -676,7 +676,7 @@ Test.prototype['throws'] = function (fn, expected, msg, extra) {
});
};

Test.prototype.doesNotThrow = function (fn, expected, msg, extra) {
Test.prototype.doesNotThrow = function doesNotThrow(fn, expected, msg, extra) {
if (typeof expected === 'string') {
msg = expected;
expected = undefined;
Expand Down Expand Up @@ -741,7 +741,7 @@ Test.prototype.doesNotMatch = function doesNotMatch(string, regexp, msg, extra)
});
};

Test.skip = function (name_, _opts, _cb) {
Test.skip = function skip(name_, _opts, _cb) {
var args = getTestArgs.apply(null, arguments);
args.opts.skip = true;
return Test(args.name, args.opts, args.cb);
Expand Down

0 comments on commit 077a108

Please sign in to comment.