UNPKG

1.24 kBJavaScriptView Raw
1// Copyright IBM Corp. 2011,2019. All Rights Reserved.
2// Node module: loopback-datasource-juggler
3// This file is licensed under the MIT License.
4// License text available at https://opensource.org/licenses/MIT
5
6/* eslint-disable camelcase */
7
8/*
9 if (!process.env.TRAVIS) {
10 var semicov = require('semicov');
11 semicov.init('lib', 'LoopbackData');
12 process.on('exit', semicov.report);
13 }
14 */
15
16'use strict';
17
18let group_name = false, EXT_EXP;
19function 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
28global.it = it;
29
30function 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
45global.context = context;
46
47exports.init = function init(external_exports) {
48 EXT_EXP = external_exports;
49 if (external_exports.done) {
50 external_exports.done();
51 }
52};
53
54function 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