Blame view

framework/thirdparty/jasmine/src/Runner.js 1.72 KB
0084d336   Administrator   Importers CRUD
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
  /**
   * Runner
   *
   * @constructor
   * @param {jasmine.Env} env
   */
  jasmine.Runner = function(env) {
    var self = this;
    self.env = env;
    self.queue = new jasmine.Queue(env);
    self.before_ = [];
    self.after_ = [];
    self.suites_ = [];
  };
  
  jasmine.Runner.prototype.execute = function() {
    var self = this;
    if (self.env.reporter.reportRunnerStarting) {
      self.env.reporter.reportRunnerStarting(this);
    }
    self.queue.start(function () {
      self.finishCallback();
    });
  };
  
  jasmine.Runner.prototype.beforeEach = function(beforeEachFunction) {
    beforeEachFunction.typeName = 'beforeEach';
    this.before_.splice(0,0,beforeEachFunction);
  };
  
  jasmine.Runner.prototype.afterEach = function(afterEachFunction) {
    afterEachFunction.typeName = 'afterEach';
    this.after_.splice(0,0,afterEachFunction);
  };
  
  
  jasmine.Runner.prototype.finishCallback = function() {
    this.env.reporter.reportRunnerResults(this);
  };
  
  jasmine.Runner.prototype.addSuite = function(suite) {
    this.suites_.push(suite);
  };
  
  jasmine.Runner.prototype.add = function(block) {
    if (block instanceof jasmine.Suite) {
      this.addSuite(block);
    }
    this.queue.add(block);
  };
  
  jasmine.Runner.prototype.specs = function () {
    var suites = this.suites();
    var specs = [];
    for (var i = 0; i < suites.length; i++) {
      specs = specs.concat(suites[i].specs());
    }
    return specs;
  };
  
  jasmine.Runner.prototype.suites = function() {
    return this.suites_;
  };
  
  jasmine.Runner.prototype.topLevelSuites = function() {
    var topLevelSuites = [];
    for (var i = 0; i < this.suites_.length; i++) {
      if (!this.suites_[i].parentSuite) {
        topLevelSuites.push(this.suites_[i]);
      }
    }
    return topLevelSuites;
  };
  
  jasmine.Runner.prototype.results = function() {
    return this.queue.results();
  };