1 | 'use strict';
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 | var Test = require('../test');
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 | module.exports = function (suite) {
|
27 | var suites = [suite];
|
28 |
|
29 | suite.on('pre-require', function (context, file, mocha) {
|
30 | var common = require('./common')(suites, context, mocha);
|
31 |
|
32 | context.before = common.before;
|
33 | context.after = common.after;
|
34 | context.beforeEach = common.beforeEach;
|
35 | context.afterEach = common.afterEach;
|
36 | context.run = mocha.options.delay && common.runWithSuite(suite);
|
37 | |
38 |
|
39 |
|
40 |
|
41 |
|
42 |
|
43 | context.describe = context.context = function (title, fn) {
|
44 | return common.suite.create({
|
45 | title: title,
|
46 | file: file,
|
47 | fn: fn
|
48 | });
|
49 | };
|
50 |
|
51 | |
52 |
|
53 |
|
54 |
|
55 | context.xdescribe = context.xcontext = context.describe.skip = function (title, fn) {
|
56 | return common.suite.skip({
|
57 | title: title,
|
58 | file: file,
|
59 | fn: fn
|
60 | });
|
61 | };
|
62 |
|
63 | |
64 |
|
65 |
|
66 |
|
67 | context.describe.only = function (title, fn) {
|
68 | return common.suite.only({
|
69 | title: title,
|
70 | file: file,
|
71 | fn: fn
|
72 | });
|
73 | };
|
74 |
|
75 | |
76 |
|
77 |
|
78 |
|
79 |
|
80 |
|
81 | context.it = context.specify = function (title, fn) {
|
82 | var suite = suites[0];
|
83 | if (suite.isPending()) {
|
84 | fn = null;
|
85 | }
|
86 | var test = new Test(title, fn);
|
87 | test.file = file;
|
88 | suite.addTest(test);
|
89 | return test;
|
90 | };
|
91 |
|
92 | |
93 |
|
94 |
|
95 |
|
96 | context.it.only = function (title, fn) {
|
97 | return common.test.only(mocha, context.it(title, fn));
|
98 | };
|
99 |
|
100 | |
101 |
|
102 |
|
103 |
|
104 | context.xit = context.xspecify = context.it.skip = function (title) {
|
105 | context.it(title);
|
106 | };
|
107 |
|
108 | |
109 |
|
110 |
|
111 | context.it.retries = function (n) {
|
112 | context.retries(n);
|
113 | };
|
114 | });
|
115 | };
|