UNPKG

520 BJavaScriptView Raw
1var Test = require('./test');
2
3module.exports = Hook;
4
5function Hook(title, fn) {
6 if (!(this instanceof Hook)) {
7 throw new TypeError('Class constructor Hook cannot be invoked without \'new\'');
8 }
9
10 if (typeof title === 'function') {
11 fn = title;
12 title = null;
13 }
14
15 this.title = title;
16 this.fn = fn;
17}
18
19Hook.prototype.test = function (testTitle) {
20 var title = this.title || (this.metadata.type + ' for "' + testTitle + '"');
21 var test = new Test(title, this.fn);
22 test.metadata = this.metadata;
23 return test;
24};