Blame view

node_modules/loopback-datasource-juggler/test/spec_helper.js 1.21 KB
f7563de62   Palak Handa   first commit
1
2
3
4
5
6
7
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
  // Copyright IBM Corp. 2011,2016. All Rights Reserved.
  // Node module: loopback-datasource-juggler
  // This file is licensed under the MIT License.
  // License text available at https://opensource.org/licenses/MIT
  'use strict';
  
  /* eslint-disable camelcase */
  
  /*
   if (!process.env.TRAVIS) {
   var semicov = require('semicov');
   semicov.init('lib', 'LoopbackData');
   process.on('exit', semicov.report);
   }
   */
  
  var group_name = false, EXT_EXP;
  function it(should, test_case) {
    check_external_exports();
    if (group_name) {
      EXT_EXP[group_name][should] = test_case;
    } else {
      EXT_EXP[should] = test_case;
    }
  }
  
  global.it = it;
  
  function context(name, tests) {
    check_external_exports();
    EXT_EXP[name] = {};
    group_name = name;
    tests({
      before: function(f) {
        it('setUp', f);
      },
      after: function(f) {
        it('tearDown', f);
      },
    });
    group_name = false;
  }
  
  global.context = context;
  
  exports.init = function init(external_exports) {
    EXT_EXP = external_exports;
    if (external_exports.done) {
      external_exports.done();
    }
  };
  
  function check_external_exports() {
    if (!EXT_EXP) throw new Error(
      'Before run this, please ensure that ' +
        'require("spec_helper").init(exports); called');
  }