1 | ;
|
2 |
|
3 | var Runnable = require('./runnable');
|
4 | var inherits = require('./utils').inherits;
|
5 |
|
6 | /**
|
7 | * Expose `Hook`.
|
8 | */
|
9 |
|
10 | module.exports = Hook;
|
11 |
|
12 | /**
|
13 | * Initialize a new `Hook` with the given `title` and callback `fn`
|
14 | *
|
15 | * @class
|
16 | * @extends Runnable
|
17 | * @param {String} title
|
18 | * @param {Function} fn
|
19 | */
|
20 | function Hook(title, fn) {
|
21 | Runnable.call(this, title, fn);
|
22 | this.type = 'hook';
|
23 | }
|
24 |
|
25 | /**
|
26 | * Inherit from `Runnable.prototype`.
|
27 | */
|
28 | inherits(Hook, Runnable);
|
29 |
|
30 | /**
|
31 | * Get or set the test `err`.
|
32 | *
|
33 | * @memberof Hook
|
34 | * @public
|
35 | * @param {Error} err
|
36 | * @return {Error}
|
37 | */
|
38 | Hook.prototype.error = function(err) {
|
39 | if (!arguments.length) {
|
40 | err = this._error;
|
41 | this._error = null;
|
42 | return err;
|
43 | }
|
44 |
|
45 | this._error = err;
|
46 | };
|