1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 | 'use strict';
|
17 |
|
18 | let group_name = false, EXT_EXP;
|
19 | function it(should, test_case) {
|
20 | check_external_exports();
|
21 | if (group_name) {
|
22 | EXT_EXP[group_name][should] = test_case;
|
23 | } else {
|
24 | EXT_EXP[should] = test_case;
|
25 | }
|
26 | }
|
27 |
|
28 | global.it = it;
|
29 |
|
30 | function context(name, tests) {
|
31 | check_external_exports();
|
32 | EXT_EXP[name] = {};
|
33 | group_name = name;
|
34 | tests({
|
35 | before: function(f) {
|
36 | it('setUp', f);
|
37 | },
|
38 | after: function(f) {
|
39 | it('tearDown', f);
|
40 | },
|
41 | });
|
42 | group_name = false;
|
43 | }
|
44 |
|
45 | global.context = context;
|
46 |
|
47 | exports.init = function init(external_exports) {
|
48 | EXT_EXP = external_exports;
|
49 | if (external_exports.done) {
|
50 | external_exports.done();
|
51 | }
|
52 | };
|
53 |
|
54 | function check_external_exports() {
|
55 | if (!EXT_EXP) throw new Error(
|
56 | 'Before run this, please ensure that ' +
|
57 | 'require("spec_helper").init(exports); called',
|
58 | );
|
59 | }
|
60 |
|