UNPKG

1.11 kBJavaScriptView Raw
1'use strict';
2
3/**
4 * Module dependencies.
5 */
6
7var Runnable = require('./runnable');
8var create = require('lodash.create');
9var isString = require('./utils').isString;
10
11/**
12 * Expose `Test`.
13 */
14
15module.exports = Test;
16
17/**
18 * Initialize a new `Test` with the given `title` and callback `fn`.
19 *
20 * @api private
21 * @param {String} title
22 * @param {Function} fn
23 */
24function Test (title, fn) {
25 if (!isString(title)) {
26 throw new Error('Test `title` should be a "string" but "' + typeof title + '" was given instead.');
27 }
28 Runnable.call(this, title, fn);
29 this.pending = !fn;
30 this.type = 'test';
31}
32
33/**
34 * Inherit from `Runnable.prototype`.
35 */
36Test.prototype = create(Runnable.prototype, {
37 constructor: Test
38});
39
40Test.prototype.clone = function () {
41 var test = new Test(this.title, this.fn);
42 test.timeout(this.timeout());
43 test.slow(this.slow());
44 test.enableTimeouts(this.enableTimeouts());
45 test.retries(this.retries());
46 test.currentRetry(this.currentRetry());
47 test.globals(this.globals());
48 test.parent = this.parent;
49 test.file = this.file;
50 test.ctx = this.ctx;
51 return test;
52};