Blame view

framework/thirdparty/jasmine/src/NestedResults.js 1.71 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
78
79
80
  /**
   * Holds results for a set of Jasmine spec. Allows for the results array to hold another jasmine.NestedResults
   *
   * @constructor
   */
  jasmine.NestedResults = function() {
    /**
     * The total count of results
     */
    this.totalCount = 0;
    /**
     * Number of passed results
     */
    this.passedCount = 0;
    /**
     * Number of failed results
     */
    this.failedCount = 0;
    /**
     * Was this suite/spec skipped?
     */
    this.skipped = false;
    /**
     * @ignore
     */
    this.items_ = [];
  };
  
  /**
   * Roll up the result counts.
   *
   * @param result
   */
  jasmine.NestedResults.prototype.rollupCounts = function(result) {
    this.totalCount += result.totalCount;
    this.passedCount += result.passedCount;
    this.failedCount += result.failedCount;
  };
  
  /**
   * Adds a log message.
   * @param values Array of message parts which will be concatenated later.
   */
  jasmine.NestedResults.prototype.log = function(values) {
    this.items_.push(new jasmine.MessageResult(values));
  };
  
  /**
   * Getter for the results: message & results.
   */
  jasmine.NestedResults.prototype.getItems = function() {
    return this.items_;
  };
  
  /**
   * Adds a result, tracking counts (total, passed, & failed)
   * @param {jasmine.ExpectationResult|jasmine.NestedResults} result
   */
  jasmine.NestedResults.prototype.addResult = function(result) {
    if (result.type != 'log') {
      if (result.items_) {
        this.rollupCounts(result);
      } else {
        this.totalCount++;
        if (result.passed()) {
          this.passedCount++;
        } else {
          this.failedCount++;
        }
      }
    }
    this.items_.push(result);
  };
  
  /**
   * @returns {Boolean} True if <b>everything</b> below passed
   */
  jasmine.NestedResults.prototype.passed = function() {
    return this.passedCount === this.totalCount;
  };