1
jasmine.HtmlReporter.ReporterView = function(dom) {
2
this.startedAt = new Date();
3
this.runningSpecCount = 0;
4
this.completeSpecCount = 0;
9
this.createResultsMenu = function() {
10
this.resultsMenu = this.createDom('span', {className: 'resultsMenu bar'},
11
this.summaryMenuItem = this.createDom('a', {className: 'summaryMenuItem', href: "#"}, '0 specs'),
13
this.detailsMenuItem = this.createDom('a', {className: 'detailsMenuItem', href: "#"}, '0 failing'));
15
this.summaryMenuItem.onclick = function() {
16
dom.reporter.className = dom.reporter.className.replace(/ showDetails/g, '');
19
this.detailsMenuItem.onclick = function() {
24
this.addSpecs = function(specs, specFilter) {
25
this.totalSpecCount = specs.length;
32
for (var i = 0; i < specs.length; i++) {
34
this.views.specs[spec.id] = new jasmine.HtmlReporter.SpecView(spec, dom, this.views);
35
if (specFilter(spec)) {
36
this.runningSpecCount++;
41
this.specComplete = function(spec) {
42
this.completeSpecCount++;
44
if (isUndefined(this.views.specs[spec.id])) {
45
this.views.specs[spec.id] = new jasmine.HtmlReporter.SpecView(spec, dom);
48
var specView = this.views.specs[spec.id];
50
switch (specView.status()) {
68
this.suiteComplete = function(suite) {
69
var suiteView = this.views.suites[suite.id];
70
if (isUndefined(suiteView)) {
76
this.refresh = function() {
78
if (isUndefined(this.resultsMenu)) {
79
this.createResultsMenu();
82
// currently running UI
83
if (isUndefined(this.runningAlert)) {
84
this.runningAlert = this.createDom('a', {href: "?", className: "runningAlert bar"});
85
dom.alert.appendChild(this.runningAlert);
87
this.runningAlert.innerHTML = "Running " + this.completeSpecCount + " of " + specPluralizedFor(this.totalSpecCount);
90
if (isUndefined(this.skippedAlert)) {
91
this.skippedAlert = this.createDom('a', {href: "?", className: "skippedAlert bar"});
94
this.skippedAlert.innerHTML = "Skipping " + this.skippedCount + " of " + specPluralizedFor(this.totalSpecCount) + " - run all";
96
if (this.skippedCount === 1 && isDefined(dom.alert)) {
97
dom.alert.appendChild(this.skippedAlert);
101
if (isUndefined(this.passedAlert)) {
102
this.passedAlert = this.createDom('span', {href: "?", className: "passingAlert bar"});
104
this.passedAlert.innerHTML = "Passing " + specPluralizedFor(this.passedCount);
107
if (isUndefined(this.failedAlert)) {
108
this.failedAlert = this.createDom('span', {href: "?", className: "failingAlert bar"});
110
this.failedAlert.innerHTML = "Failing " + specPluralizedFor(this.failedCount);
112
if (this.failedCount === 1 && isDefined(dom.alert)) {
113
dom.alert.appendChild(this.failedAlert);
114
dom.alert.appendChild(this.resultsMenu);
118
this.summaryMenuItem.innerHTML = "" + specPluralizedFor(this.runningSpecCount);
119
this.detailsMenuItem.innerHTML = "" + this.failedCount + " failing";
122
this.complete = function() {
123
dom.alert.removeChild(this.runningAlert);
125
this.skippedAlert.innerHTML = "Ran " + this.runningSpecCount + " of " + specPluralizedFor(this.totalSpecCount) + " - run all";
127
if (this.failedCount === 0) {
128
dom.alert.appendChild(this.createDom('span', {className: 'passingAlert bar'}, "Passing " + specPluralizedFor(this.passedCount)));
133
dom.banner.appendChild(this.createDom('span', {className: 'duration'}, "finished in " + ((new Date().getTime() - this.startedAt.getTime()) / 1000) + "s"));
138
function showDetails() {
139
if (dom.reporter.className.search(/showDetails/) === -1) {
140
dom.reporter.className += " showDetails";
144
function isUndefined(obj) {
145
return typeof obj === 'undefined';
148
function isDefined(obj) {
149
return !isUndefined(obj);
152
function specPluralizedFor(count) {
153
var str = count + " spec";
162
jasmine.HtmlReporterHelpers.addHelpers(jasmine.HtmlReporter.ReporterView);