~ps-jenkins/cordova-ubuntu-tests/latestsnapshot-2.11+14.04.20131106-0ubuntu1

« back to all changes in this revision

Viewing changes to www/autotest/html/SpecView.js

  • Committer: VĂ­ctor R. Ruiz
  • Date: 2013-07-25 13:09:34 UTC
  • Revision ID: victor.ruiz@canonical.com-20130725130934-d4q95mh8eehbv363
Initial import

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
jasmine.HtmlReporter.SpecView = function(spec, dom, views) {
 
2
  this.spec = spec;
 
3
  this.dom = dom;
 
4
  this.views = views;
 
5
 
 
6
  this.symbol = this.createDom('li', { className: 'pending' });
 
7
  this.dom.symbolSummary.appendChild(this.symbol);
 
8
 
 
9
  this.summary = this.createDom('div', { className: 'specSummary' },
 
10
      this.createDom('a', {
 
11
        className: 'description',
 
12
        href: '?spec=' + encodeURIComponent(this.spec.getFullName()),
 
13
        title: this.spec.getFullName()
 
14
      }, this.spec.description)
 
15
  );
 
16
 
 
17
  this.detail = this.createDom('div', { className: 'specDetail' },
 
18
      this.createDom('a', {
 
19
        className: 'description',
 
20
        href: '?spec=' + encodeURIComponent(this.spec.getFullName()),
 
21
        title: this.spec.getFullName()
 
22
      }, this.spec.getFullName())
 
23
  );
 
24
};
 
25
 
 
26
jasmine.HtmlReporter.SpecView.prototype.status = function() {
 
27
  return this.getSpecStatus(this.spec);
 
28
};
 
29
 
 
30
jasmine.HtmlReporter.SpecView.prototype.refresh = function() {
 
31
  this.symbol.className = this.status();
 
32
 
 
33
  switch (this.status()) {
 
34
    case 'skipped':
 
35
      break;
 
36
 
 
37
    case 'passed':
 
38
      this.appendSummaryToSuiteDiv();
 
39
      break;
 
40
 
 
41
    case 'failed':
 
42
      this.appendSummaryToSuiteDiv();
 
43
      this.appendFailureDetail();
 
44
      break;
 
45
  }
 
46
};
 
47
 
 
48
jasmine.HtmlReporter.SpecView.prototype.appendSummaryToSuiteDiv = function() {
 
49
  this.summary.className += ' ' + this.status();
 
50
  this.appendToSummary(this.spec, this.summary);
 
51
};
 
52
 
 
53
jasmine.HtmlReporter.SpecView.prototype.appendFailureDetail = function() {
 
54
  this.detail.className += ' ' + this.status();
 
55
 
 
56
  var resultItems = this.spec.results().getItems();
 
57
  var messagesDiv = this.createDom('div', { className: 'messages' });
 
58
 
 
59
  for (var i = 0; i < resultItems.length; i++) {
 
60
    var result = resultItems[i];
 
61
 
 
62
    if (result.type == 'log') {
 
63
      messagesDiv.appendChild(this.createDom('div', {className: 'resultMessage log'}, result.toString()));
 
64
    } else if (result.type == 'expect' && result.passed && !result.passed()) {
 
65
      messagesDiv.appendChild(this.createDom('div', {className: 'resultMessage fail'}, result.message));
 
66
 
 
67
      if (result.trace.stack) {
 
68
        messagesDiv.appendChild(this.createDom('div', {className: 'stackTrace'}, result.trace.stack));
 
69
      }
 
70
    }
 
71
  }
 
72
 
 
73
  if (messagesDiv.childNodes.length > 0) {
 
74
    this.detail.appendChild(messagesDiv);
 
75
    this.dom.details.appendChild(this.detail);
 
76
  }
 
77
};
 
78
 
 
79
jasmine.HtmlReporterHelpers.addHelpers(jasmine.HtmlReporter.SpecView);