mirror of https://github.com/lukechilds/ava.git
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
467 B
24 lines
467 B
var Test = require('./test');
|
|
|
|
module.exports = Hook;
|
|
|
|
function Hook(title, fn) {
|
|
if (!(this instanceof Hook)) {
|
|
return new Hook(title, fn);
|
|
}
|
|
|
|
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;
|
|
};
|
|
|