You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

24 lines
520 B

var Test = require('./test');
module.exports = Hook;
function Hook(title, fn) {
if (!(this instanceof Hook)) {
throw new TypeError('Class constructor Hook cannot be invoked without \'new\'');
}
if (typeof title === 'function') {
fn = title;
title = null;
}
this.title = title;
this.fn = fn;
}
Hook.prototype.test = function (testTitle) {
var title = this.title || (this.metadata.type + ' for "' + testTitle + '"');
var test = new Test(title, this.fn);
test.metadata = this.metadata;
return test;
};