1 | var Test = require('./test');
|
2 |
|
3 | module.exports = Hook;
|
4 |
|
5 | function 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 |
|
19 | Hook.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 | };
|