Skip to content

Commit 6872461

Browse files
committed
update Jasmine to 1.3.1
1 parent db499a8 commit 6872461

File tree

3 files changed

+185
-48
lines changed

3 files changed

+185
-48
lines changed

spec/jasmine/jasmine-html.js

Lines changed: 77 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ jasmine.HtmlReporter = function(_doc) {
7878

7979
createReporterDom(runner.env.versionString());
8080
doc.body.appendChild(dom.reporter);
81+
setExceptionHandling();
8182

8283
reporterView = new jasmine.HtmlReporter.ReporterView(dom);
8384
reporterView.addSpecs(specs, self.specFilter);
@@ -131,7 +132,7 @@ jasmine.HtmlReporter = function(_doc) {
131132
}
132133

133134
var paramMap = [];
134-
var params = doc.location.search.substring(1).split('&');
135+
var params = jasmine.HtmlReporter.parameters(doc);
135136

136137
for (var i = 0; i < params.length; i++) {
137138
var p = params[i].split('=');
@@ -151,14 +152,78 @@ jasmine.HtmlReporter = function(_doc) {
151152
self.createDom('span', { className: 'version' }, version)),
152153

153154
dom.symbolSummary = self.createDom('ul', {className: 'symbolSummary'}),
154-
dom.alert = self.createDom('div', {className: 'alert'}),
155+
dom.alert = self.createDom('div', {className: 'alert'},
156+
self.createDom('span', { className: 'exceptions' },
157+
self.createDom('label', { className: 'label', 'for': 'no_try_catch' }, 'No try/catch'),
158+
self.createDom('input', { id: 'no_try_catch', type: 'checkbox' }))),
155159
dom.results = self.createDom('div', {className: 'results'},
156160
dom.summary = self.createDom('div', { className: 'summary' }),
157161
dom.details = self.createDom('div', { id: 'details' }))
158162
);
159163
}
164+
165+
function noTryCatch() {
166+
return window.location.search.match(/catch=false/);
167+
}
168+
169+
function searchWithCatch() {
170+
var params = jasmine.HtmlReporter.parameters(window.document);
171+
var removed = false;
172+
var i = 0;
173+
174+
while (!removed && i < params.length) {
175+
if (params[i].match(/catch=/)) {
176+
params.splice(i, 1);
177+
removed = true;
178+
}
179+
i++;
180+
}
181+
if (jasmine.CATCH_EXCEPTIONS) {
182+
params.push("catch=false");
183+
}
184+
185+
return params.join("&");
186+
}
187+
188+
function setExceptionHandling() {
189+
var chxCatch = document.getElementById('no_try_catch');
190+
191+
if (noTryCatch()) {
192+
chxCatch.setAttribute('checked', true);
193+
jasmine.CATCH_EXCEPTIONS = false;
194+
}
195+
chxCatch.onclick = function() {
196+
window.location.search = searchWithCatch();
197+
};
198+
}
199+
};
200+
jasmine.HtmlReporter.parameters = function(doc) {
201+
var paramStr = doc.location.search.substring(1);
202+
var params = [];
203+
204+
if (paramStr.length > 0) {
205+
params = paramStr.split('&');
206+
}
207+
return params;
208+
}
209+
jasmine.HtmlReporter.sectionLink = function(sectionName) {
210+
var link = '?';
211+
var params = [];
212+
213+
if (sectionName) {
214+
params.push('spec=' + encodeURIComponent(sectionName));
215+
}
216+
if (!jasmine.CATCH_EXCEPTIONS) {
217+
params.push("catch=false");
218+
}
219+
if (params.length > 0) {
220+
link += params.join("&");
221+
}
222+
223+
return link;
160224
};
161-
jasmine.HtmlReporterHelpers.addHelpers(jasmine.HtmlReporter);jasmine.HtmlReporter.ReporterView = function(dom) {
225+
jasmine.HtmlReporterHelpers.addHelpers(jasmine.HtmlReporter);
226+
jasmine.HtmlReporter.ReporterView = function(dom) {
162227
this.startedAt = new Date();
163228
this.runningSpecCount = 0;
164229
this.completeSpecCount = 0;
@@ -241,14 +306,14 @@ jasmine.HtmlReporterHelpers.addHelpers(jasmine.HtmlReporter);jasmine.HtmlReporte
241306

242307
// currently running UI
243308
if (isUndefined(this.runningAlert)) {
244-
this.runningAlert = this.createDom('a', {href: "?", className: "runningAlert bar"});
309+
this.runningAlert = this.createDom('a', { href: jasmine.HtmlReporter.sectionLink(), className: "runningAlert bar" });
245310
dom.alert.appendChild(this.runningAlert);
246311
}
247312
this.runningAlert.innerHTML = "Running " + this.completeSpecCount + " of " + specPluralizedFor(this.totalSpecCount);
248313

249314
// skipped specs UI
250315
if (isUndefined(this.skippedAlert)) {
251-
this.skippedAlert = this.createDom('a', {href: "?", className: "skippedAlert bar"});
316+
this.skippedAlert = this.createDom('a', { href: jasmine.HtmlReporter.sectionLink(), className: "skippedAlert bar" });
252317
}
253318

254319
this.skippedAlert.innerHTML = "Skipping " + this.skippedCount + " of " + specPluralizedFor(this.totalSpecCount) + " - run all";
@@ -259,7 +324,7 @@ jasmine.HtmlReporterHelpers.addHelpers(jasmine.HtmlReporter);jasmine.HtmlReporte
259324

260325
// passing specs UI
261326
if (isUndefined(this.passedAlert)) {
262-
this.passedAlert = this.createDom('span', {href: "?", className: "passingAlert bar"});
327+
this.passedAlert = this.createDom('span', { href: jasmine.HtmlReporter.sectionLink(), className: "passingAlert bar" });
263328
}
264329
this.passedAlert.innerHTML = "Passing " + specPluralizedFor(this.passedCount);
265330

@@ -331,11 +396,11 @@ jasmine.HtmlReporter.SpecView = function(spec, dom, views) {
331396
this.dom.symbolSummary.appendChild(this.symbol);
332397

333398
this.summary = this.createDom('div', { className: 'specSummary' },
334-
this.createDom('a', {
335-
className: 'description',
336-
href: '?spec=' + encodeURIComponent(this.spec.getFullName()),
337-
title: this.spec.getFullName()
338-
}, this.spec.description)
399+
this.createDom('a', {
400+
className: 'description',
401+
href: jasmine.HtmlReporter.sectionLink(this.spec.getFullName()),
402+
title: this.spec.getFullName()
403+
}, this.spec.description)
339404
);
340405

341406
this.detail = this.createDom('div', { className: 'specDetail' },
@@ -406,7 +471,7 @@ jasmine.HtmlReporterHelpers.addHelpers(jasmine.HtmlReporter.SpecView);jasmine.Ht
406471
this.views = views;
407472

408473
this.element = this.createDom('div', { className: 'suite' },
409-
this.createDom('a', { className: 'description', href: '?spec=' + encodeURIComponent(this.suite.getFullName()) }, this.suite.description)
474+
this.createDom('a', { className: 'description', href: jasmine.HtmlReporter.sectionLink(this.suite.getFullName()) }, this.suite.description)
410475
);
411476

412477
this.appendToSummary(this.suite, this.element);

spec/jasmine/jasmine.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ body { background-color: #eeeeee; padding: 0; margin: 5px; overflow-y: scroll; }
1919
#HTMLReporter .symbolSummary li.skipped:before { color: #bababa; content: "\02022"; }
2020
#HTMLReporter .symbolSummary li.pending { line-height: 11px; }
2121
#HTMLReporter .symbolSummary li.pending:before { color: #aaaaaa; content: "-"; }
22+
#HTMLReporter .exceptions { color: #fff; float: right; margin-top: 5px; margin-right: 5px; }
2223
#HTMLReporter .bar { line-height: 28px; font-size: 14px; display: block; color: #eee; }
2324
#HTMLReporter .runningAlert { background-color: #666666; }
2425
#HTMLReporter .skippedAlert { background-color: #aaaaaa; }

0 commit comments

Comments
 (0)