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 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 |
|
34 | module.exports = function (suite) {
|
35 | var suites = [suite];
|
36 |
|
37 | suite.on('pre-require', function (context, file, mocha) {
|
38 | var common = require('./common')(suites, context, mocha);
|
39 |
|
40 | context.setup = common.beforeEach;
|
41 | context.teardown = common.afterEach;
|
42 | context.suiteSetup = common.before;
|
43 | context.suiteTeardown = common.after;
|
44 | context.run = mocha.options.delay && common.runWithSuite(suite);
|
45 |
|
46 | |
47 |
|
48 |
|
49 |
|
50 | context.suite = function (title, fn) {
|
51 | return common.suite.create({
|
52 | title: title,
|
53 | file: file,
|
54 | fn: fn
|
55 | });
|
56 | };
|
57 |
|
58 | |
59 |
|
60 |
|
61 | context.suite.skip = function (title, fn) {
|
62 | return common.suite.skip({
|
63 | title: title,
|
64 | file: file,
|
65 | fn: fn
|
66 | });
|
67 | };
|
68 |
|
69 | |
70 |
|
71 |
|
72 | context.suite.only = function (title, fn) {
|
73 | return common.suite.only({
|
74 | title: title,
|
75 | file: file,
|
76 | fn: fn
|
77 | });
|
78 | };
|
79 |
|
80 | |
81 |
|
82 |
|
83 |
|
84 | context.test = function (title, fn) {
|
85 | var suite = suites[0];
|
86 | if (suite.isPending()) {
|
87 | fn = null;
|
88 | }
|
89 | var test = new Test(title, fn);
|
90 | test.file = file;
|
91 | suite.addTest(test);
|
92 | return test;
|
93 | };
|
94 |
|
95 | |
96 |
|
97 |
|
98 |
|
99 | context.test.only = function (title, fn) {
|
100 | return common.test.only(mocha, context.test(title, fn));
|
101 | };
|
102 |
|
103 | context.test.skip = common.test.skip;
|
104 | context.test.retries = common.test.retries;
|
105 | });
|
106 | };
|