summaryrefslogtreecommitdiff
path: root/xstatic/pkg/jasmine/data/jasmine-html.js
diff options
context:
space:
mode:
Diffstat (limited to 'xstatic/pkg/jasmine/data/jasmine-html.js')
-rwxr-xr-x[-rw-r--r--]xstatic/pkg/jasmine/data/jasmine-html.js933
1 files changed, 328 insertions, 605 deletions
diff --git a/xstatic/pkg/jasmine/data/jasmine-html.js b/xstatic/pkg/jasmine/data/jasmine-html.js
index 543d569..898108b 100644..100755
--- a/xstatic/pkg/jasmine/data/jasmine-html.js
+++ b/xstatic/pkg/jasmine/data/jasmine-html.js
@@ -1,681 +1,404 @@
-jasmine.HtmlReporterHelpers = {};
-
-jasmine.HtmlReporterHelpers.createDom = function(type, attrs, childrenVarArgs) {
- var el = document.createElement(type);
-
- for (var i = 2; i < arguments.length; i++) {
- var child = arguments[i];
-
- if (typeof child === 'string') {
- el.appendChild(document.createTextNode(child));
- } else {
- if (child) {
- el.appendChild(child);
- }
- }
- }
-
- for (var attr in attrs) {
- if (attr == "className") {
- el[attr] = attrs[attr];
- } else {
- el.setAttribute(attr, attrs[attr]);
- }
- }
-
- return el;
-};
-
-jasmine.HtmlReporterHelpers.getSpecStatus = function(child) {
- var results = child.results();
- var status = results.passed() ? 'passed' : 'failed';
- if (results.skipped) {
- status = 'skipped';
- }
-
- return status;
-};
-
-jasmine.HtmlReporterHelpers.appendToSummary = function(child, childElement) {
- var parentDiv = this.dom.summary;
- var parentSuite = (typeof child.parentSuite == 'undefined') ? 'suite' : 'parentSuite';
- var parent = child[parentSuite];
-
- if (parent) {
- if (typeof this.views.suites[parent.id] == 'undefined') {
- this.views.suites[parent.id] = new jasmine.HtmlReporter.SuiteView(parent, this.dom, this.views);
- }
- parentDiv = this.views.suites[parent.id].element;
- }
-
- parentDiv.appendChild(childElement);
-};
-
-
-jasmine.HtmlReporterHelpers.addHelpers = function(ctor) {
- for(var fn in jasmine.HtmlReporterHelpers) {
- ctor.prototype[fn] = jasmine.HtmlReporterHelpers[fn];
- }
+/*
+Copyright (c) 2008-2014 Pivotal Labs
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+jasmineRequire.html = function(j$) {
+ j$.ResultsNode = jasmineRequire.ResultsNode();
+ j$.HtmlReporter = jasmineRequire.HtmlReporter(j$);
+ j$.QueryString = jasmineRequire.QueryString();
+ j$.HtmlSpecFilter = jasmineRequire.HtmlSpecFilter();
};
-jasmine.HtmlReporter = function(_doc) {
- var self = this;
- var doc = _doc || window.document;
+jasmineRequire.HtmlReporter = function(j$) {
- var reporterView;
-
- var dom = {};
-
- // Jasmine Reporter Public Interface
- self.logRunningSpecs = false;
-
- self.reportRunnerStarting = function(runner) {
- var specs = runner.specs() || [];
-
- if (specs.length == 0) {
- return;
- }
-
- createReporterDom(runner.env.versionString());
- doc.body.appendChild(dom.reporter);
- setExceptionHandling();
-
- reporterView = new jasmine.HtmlReporter.ReporterView(dom);
- reporterView.addSpecs(specs, self.specFilter);
- };
-
- self.reportRunnerResults = function(runner) {
- reporterView && reporterView.complete();
- };
-
- self.reportSuiteResults = function(suite) {
- reporterView.suiteComplete(suite);
- };
-
- self.reportSpecStarting = function(spec) {
- if (self.logRunningSpecs) {
- self.log('>> Jasmine Running ' + spec.suite.description + ' ' + spec.description + '...');
- }
- };
-
- self.reportSpecResults = function(spec) {
- reporterView.specComplete(spec);
- };
-
- self.log = function() {
- var console = jasmine.getGlobal().console;
- if (console && console.log) {
- if (console.log.apply) {
- console.log.apply(console, arguments);
- } else {
- console.log(arguments); // ie fix: console.log.apply doesn't exist on ie
- }
- }
+ var noopTimer = {
+ start: function() {},
+ elapsed: function() { return 0; }
};
- self.specFilter = function(spec) {
- if (!focusedSpecName()) {
- return true;
- }
+ function HtmlReporter(options) {
+ var env = options.env || {},
+ getContainer = options.getContainer,
+ createElement = options.createElement,
+ createTextNode = options.createTextNode,
+ onRaiseExceptionsClick = options.onRaiseExceptionsClick || function() {},
+ timer = options.timer || noopTimer,
+ results = [],
+ specsExecuted = 0,
+ failureCount = 0,
+ pendingSpecCount = 0,
+ htmlReporterMain,
+ symbols,
+ failedSuites = [];
+
+ this.initialize = function() {
+ clearPrior();
+ htmlReporterMain = createDom('div', {className: 'jasmine_html-reporter'},
+ createDom('div', {className: 'banner'},
+ createDom('a', {className: 'title', href: 'http://jasmine.github.io/', target: '_blank'}),
+ createDom('span', {className: 'version'}, j$.version)
+ ),
+ createDom('ul', {className: 'symbol-summary'}),
+ createDom('div', {className: 'alert'}),
+ createDom('div', {className: 'results'},
+ createDom('div', {className: 'failures'})
+ )
+ );
+ getContainer().appendChild(htmlReporterMain);
- return spec.getFullName().indexOf(focusedSpecName()) === 0;
- };
+ symbols = find('.symbol-summary');
+ };
- return self;
+ var totalSpecsDefined;
+ this.jasmineStarted = function(options) {
+ totalSpecsDefined = options.totalSpecsDefined || 0;
+ timer.start();
+ };
- function focusedSpecName() {
- var specName;
+ var summary = createDom('div', {className: 'summary'});
- (function memoizeFocusedSpec() {
- if (specName) {
- return;
- }
+ var topResults = new j$.ResultsNode({}, '', null),
+ currentParent = topResults;
- var paramMap = [];
- var params = jasmine.HtmlReporter.parameters(doc);
+ this.suiteStarted = function(result) {
+ currentParent.addChild(result, 'suite');
+ currentParent = currentParent.last();
+ };
- for (var i = 0; i < params.length; i++) {
- var p = params[i].split('=');
- paramMap[decodeURIComponent(p[0])] = decodeURIComponent(p[1]);
+ this.suiteDone = function(result) {
+ if (result.status == 'failed') {
+ failedSuites.push(result);
}
- specName = paramMap.spec;
- })();
-
- return specName;
- }
-
- function createReporterDom(version) {
- dom.reporter = self.createDom('div', { id: 'HTMLReporter', className: 'jasmine_reporter' },
- dom.banner = self.createDom('div', { className: 'banner' },
- self.createDom('span', { className: 'title' }, "Jasmine "),
- self.createDom('span', { className: 'version' }, version)),
-
- dom.symbolSummary = self.createDom('ul', {className: 'symbolSummary'}),
- dom.alert = self.createDom('div', {className: 'alert'},
- self.createDom('span', { className: 'exceptions' },
- self.createDom('label', { className: 'label', 'for': 'no_try_catch' }, 'No try/catch'),
- self.createDom('input', { id: 'no_try_catch', type: 'checkbox' }))),
- dom.results = self.createDom('div', {className: 'results'},
- dom.summary = self.createDom('div', { className: 'summary' }),
- dom.details = self.createDom('div', { id: 'details' }))
- );
- }
-
- function noTryCatch() {
- return window.location.search.match(/catch=false/);
- }
-
- function searchWithCatch() {
- var params = jasmine.HtmlReporter.parameters(window.document);
- var removed = false;
- var i = 0;
-
- while (!removed && i < params.length) {
- if (params[i].match(/catch=/)) {
- params.splice(i, 1);
- removed = true;
+ if (currentParent == topResults) {
+ return;
}
- i++;
- }
- if (jasmine.CATCH_EXCEPTIONS) {
- params.push("catch=false");
- }
-
- return params.join("&");
- }
- function setExceptionHandling() {
- var chxCatch = document.getElementById('no_try_catch');
-
- if (noTryCatch()) {
- chxCatch.setAttribute('checked', true);
- jasmine.CATCH_EXCEPTIONS = false;
- }
- chxCatch.onclick = function() {
- window.location.search = searchWithCatch();
+ currentParent = currentParent.parent;
};
- }
-};
-jasmine.HtmlReporter.parameters = function(doc) {
- var paramStr = doc.location.search.substring(1);
- var params = [];
-
- if (paramStr.length > 0) {
- params = paramStr.split('&');
- }
- return params;
-}
-jasmine.HtmlReporter.sectionLink = function(sectionName) {
- var link = '?';
- var params = [];
-
- if (sectionName) {
- params.push('spec=' + encodeURIComponent(sectionName));
- }
- if (!jasmine.CATCH_EXCEPTIONS) {
- params.push("catch=false");
- }
- if (params.length > 0) {
- link += params.join("&");
- }
- return link;
-};
-jasmine.HtmlReporterHelpers.addHelpers(jasmine.HtmlReporter);
-jasmine.HtmlReporter.ReporterView = function(dom) {
- this.startedAt = new Date();
- this.runningSpecCount = 0;
- this.completeSpecCount = 0;
- this.passedCount = 0;
- this.failedCount = 0;
- this.skippedCount = 0;
-
- this.createResultsMenu = function() {
- this.resultsMenu = this.createDom('span', {className: 'resultsMenu bar'},
- this.summaryMenuItem = this.createDom('a', {className: 'summaryMenuItem', href: "#"}, '0 specs'),
- ' | ',
- this.detailsMenuItem = this.createDom('a', {className: 'detailsMenuItem', href: "#"}, '0 failing'));
-
- this.summaryMenuItem.onclick = function() {
- dom.reporter.className = dom.reporter.className.replace(/ showDetails/g, '');
+ this.specStarted = function(result) {
+ currentParent.addChild(result, 'spec');
};
- this.detailsMenuItem.onclick = function() {
- showDetails();
- };
- };
+ var failures = [];
+ this.specDone = function(result) {
+ if(noExpectations(result) && typeof console !== 'undefined' && typeof console.error !== 'undefined') {
+ console.error('Spec \'' + result.fullName + '\' has no expectations.');
+ }
- this.addSpecs = function(specs, specFilter) {
- this.totalSpecCount = specs.length;
+ if (result.status != 'disabled') {
+ specsExecuted++;
+ }
- this.views = {
- specs: {},
- suites: {}
- };
+ symbols.appendChild(createDom('li', {
+ className: noExpectations(result) ? 'empty' : result.status,
+ id: 'spec_' + result.id,
+ title: result.fullName
+ }
+ ));
+
+ if (result.status == 'failed') {
+ failureCount++;
+
+ var failure =
+ createDom('div', {className: 'spec-detail failed'},
+ createDom('div', {className: 'description'},
+ createDom('a', {title: result.fullName, href: specHref(result)}, result.fullName)
+ ),
+ createDom('div', {className: 'messages'})
+ );
+ var messages = failure.childNodes[1];
+
+ for (var i = 0; i < result.failedExpectations.length; i++) {
+ var expectation = result.failedExpectations[i];
+ messages.appendChild(createDom('div', {className: 'result-message'}, expectation.message));
+ messages.appendChild(createDom('div', {className: 'stack-trace'}, expectation.stack));
+ }
+
+ failures.push(failure);
+ }
- for (var i = 0; i < specs.length; i++) {
- var spec = specs[i];
- this.views.specs[spec.id] = new jasmine.HtmlReporter.SpecView(spec, dom, this.views);
- if (specFilter(spec)) {
- this.runningSpecCount++;
+ if (result.status == 'pending') {
+ pendingSpecCount++;
}
- }
- };
+ };
- this.specComplete = function(spec) {
- this.completeSpecCount++;
+ this.jasmineDone = function() {
+ var banner = find('.banner');
+ banner.appendChild(createDom('span', {className: 'duration'}, 'finished in ' + timer.elapsed() / 1000 + 's'));
+
+ var alert = find('.alert');
+
+ alert.appendChild(createDom('span', { className: 'exceptions' },
+ createDom('label', { className: 'label', 'for': 'raise-exceptions' }, 'raise exceptions'),
+ createDom('input', {
+ className: 'raise',
+ id: 'raise-exceptions',
+ type: 'checkbox'
+ })
+ ));
+ var checkbox = find('#raise-exceptions');
+
+ checkbox.checked = !env.catchingExceptions();
+ checkbox.onclick = onRaiseExceptionsClick;
+
+ if (specsExecuted < totalSpecsDefined) {
+ var skippedMessage = 'Ran ' + specsExecuted + ' of ' + totalSpecsDefined + ' specs - run all';
+ alert.appendChild(
+ createDom('span', {className: 'bar skipped'},
+ createDom('a', {href: '?', title: 'Run all specs'}, skippedMessage)
+ )
+ );
+ }
+ var statusBarMessage = '';
+ var statusBarClassName = 'bar ';
- if (isUndefined(this.views.specs[spec.id])) {
- this.views.specs[spec.id] = new jasmine.HtmlReporter.SpecView(spec, dom);
- }
+ if (totalSpecsDefined > 0) {
+ statusBarMessage += pluralize('spec', specsExecuted) + ', ' + pluralize('failure', failureCount);
+ if (pendingSpecCount) { statusBarMessage += ', ' + pluralize('pending spec', pendingSpecCount); }
+ statusBarClassName += (failureCount > 0) ? 'failed' : 'passed';
+ } else {
+ statusBarClassName += 'skipped';
+ statusBarMessage += 'No specs found';
+ }
- var specView = this.views.specs[spec.id];
+ alert.appendChild(createDom('span', {className: statusBarClassName}, statusBarMessage));
- switch (specView.status()) {
- case 'passed':
- this.passedCount++;
- break;
+ for(i = 0; i < failedSuites.length; i++) {
+ var failedSuite = failedSuites[i];
+ for(var j = 0; j < failedSuite.failedExpectations.length; j++) {
+ var errorBarMessage = 'AfterAll ' + failedSuite.failedExpectations[j].message;
+ var errorBarClassName = 'bar errored';
+ alert.appendChild(createDom('span', {className: errorBarClassName}, errorBarMessage));
+ }
+ }
- case 'failed':
- this.failedCount++;
- break;
+ var results = find('.results');
+ results.appendChild(summary);
+
+ summaryList(topResults, summary);
+
+ function summaryList(resultsTree, domParent) {
+ var specListNode;
+ for (var i = 0; i < resultsTree.children.length; i++) {
+ var resultNode = resultsTree.children[i];
+ if (resultNode.type == 'suite') {
+ var suiteListNode = createDom('ul', {className: 'suite', id: 'suite-' + resultNode.result.id},
+ createDom('li', {className: 'suite-detail'},
+ createDom('a', {href: specHref(resultNode.result)}, resultNode.result.description)
+ )
+ );
+
+ summaryList(resultNode, suiteListNode);
+ domParent.appendChild(suiteListNode);
+ }
+ if (resultNode.type == 'spec') {
+ if (domParent.getAttribute('class') != 'specs') {
+ specListNode = createDom('ul', {className: 'specs'});
+ domParent.appendChild(specListNode);
+ }
+ var specDescription = resultNode.result.description;
+ if(noExpectations(resultNode.result)) {
+ specDescription = 'SPEC HAS NO EXPECTATIONS ' + specDescription;
+ }
+ specListNode.appendChild(
+ createDom('li', {
+ className: resultNode.result.status,
+ id: 'spec-' + resultNode.result.id
+ },
+ createDom('a', {href: specHref(resultNode.result)}, specDescription)
+ )
+ );
+ }
+ }
+ }
- case 'skipped':
- this.skippedCount++;
- break;
- }
+ if (failures.length) {
+ alert.appendChild(
+ createDom('span', {className: 'menu bar spec-list'},
+ createDom('span', {}, 'Spec List | '),
+ createDom('a', {className: 'failures-menu', href: '#'}, 'Failures')));
+ alert.appendChild(
+ createDom('span', {className: 'menu bar failure-list'},
+ createDom('a', {className: 'spec-list-menu', href: '#'}, 'Spec List'),
+ createDom('span', {}, ' | Failures ')));
+
+ find('.failures-menu').onclick = function() {
+ setMenuModeTo('failure-list');
+ };
+ find('.spec-list-menu').onclick = function() {
+ setMenuModeTo('spec-list');
+ };
+
+ setMenuModeTo('failure-list');
+
+ var failureNode = find('.failures');
+ for (var i = 0; i < failures.length; i++) {
+ failureNode.appendChild(failures[i]);
+ }
+ }
+ };
- specView.refresh();
- this.refresh();
- };
+ return this;
- this.suiteComplete = function(suite) {
- var suiteView = this.views.suites[suite.id];
- if (isUndefined(suiteView)) {
- return;
+ function find(selector) {
+ return getContainer().querySelector('.jasmine_html-reporter ' + selector);
}
- suiteView.refresh();
- };
- this.refresh = function() {
-
- if (isUndefined(this.resultsMenu)) {
- this.createResultsMenu();
+ function clearPrior() {
+ // return the reporter
+ var oldReporter = find('');
+
+ if(oldReporter) {
+ getContainer().removeChild(oldReporter);
+ }
}
- // currently running UI
- if (isUndefined(this.runningAlert)) {
- this.runningAlert = this.createDom('a', { href: jasmine.HtmlReporter.sectionLink(), className: "runningAlert bar" });
- dom.alert.appendChild(this.runningAlert);
- }
- this.runningAlert.innerHTML = "Running " + this.completeSpecCount + " of " + specPluralizedFor(this.totalSpecCount);
+ function createDom(type, attrs, childrenVarArgs) {
+ var el = createElement(type);
- // skipped specs UI
- if (isUndefined(this.skippedAlert)) {
- this.skippedAlert = this.createDom('a', { href: jasmine.HtmlReporter.sectionLink(), className: "skippedAlert bar" });
- }
+ for (var i = 2; i < arguments.length; i++) {
+ var child = arguments[i];
- this.skippedAlert.innerHTML = "Skipping " + this.skippedCount + " of " + specPluralizedFor(this.totalSpecCount) + " - run all";
+ if (typeof child === 'string') {
+ el.appendChild(createTextNode(child));
+ } else {
+ if (child) {
+ el.appendChild(child);
+ }
+ }
+ }
- if (this.skippedCount === 1 && isDefined(dom.alert)) {
- dom.alert.appendChild(this.skippedAlert);
- }
+ for (var attr in attrs) {
+ if (attr == 'className') {
+ el[attr] = attrs[attr];
+ } else {
+ el.setAttribute(attr, attrs[attr]);
+ }
+ }
- // passing specs UI
- if (isUndefined(this.passedAlert)) {
- this.passedAlert = this.createDom('span', { href: jasmine.HtmlReporter.sectionLink(), className: "passingAlert bar" });
+ return el;
}
- this.passedAlert.innerHTML = "Passing " + specPluralizedFor(this.passedCount);
- // failing specs UI
- if (isUndefined(this.failedAlert)) {
- this.failedAlert = this.createDom('span', {href: "?", className: "failingAlert bar"});
- }
- this.failedAlert.innerHTML = "Failing " + specPluralizedFor(this.failedCount);
+ function pluralize(singular, count) {
+ var word = (count == 1 ? singular : singular + 's');
- if (this.failedCount === 1 && isDefined(dom.alert)) {
- dom.alert.appendChild(this.failedAlert);
- dom.alert.appendChild(this.resultsMenu);
+ return '' + count + ' ' + word;
}
- // summary info
- this.summaryMenuItem.innerHTML = "" + specPluralizedFor(this.runningSpecCount);
- this.detailsMenuItem.innerHTML = "" + this.failedCount + " failing";
- };
-
- this.complete = function() {
- dom.alert.removeChild(this.runningAlert);
-
- this.skippedAlert.innerHTML = "Ran " + this.runningSpecCount + " of " + specPluralizedFor(this.totalSpecCount) + " - run all";
-
- if (this.failedCount === 0) {
- dom.alert.appendChild(this.createDom('span', {className: 'passingAlert bar'}, "Passing " + specPluralizedFor(this.passedCount)));
- } else {
- showDetails();
+ function specHref(result) {
+ return '?spec=' + encodeURIComponent(result.fullName);
}
- dom.banner.appendChild(this.createDom('span', {className: 'duration'}, "finished in " + ((new Date().getTime() - this.startedAt.getTime()) / 1000) + "s"));
- };
-
- return this;
-
- function showDetails() {
- if (dom.reporter.className.search(/showDetails/) === -1) {
- dom.reporter.className += " showDetails";
+ function setMenuModeTo(mode) {
+ htmlReporterMain.setAttribute('class', 'jasmine_html-reporter ' + mode);
}
- }
-
- function isUndefined(obj) {
- return typeof obj === 'undefined';
- }
- function isDefined(obj) {
- return !isUndefined(obj);
- }
-
- function specPluralizedFor(count) {
- var str = count + " spec";
- if (count > 1) {
- str += "s"
+ function noExpectations(result) {
+ return (result.failedExpectations.length + result.passedExpectations.length) === 0 &&
+ result.status === 'passed';
}
- return str;
- }
-
-};
-
-jasmine.HtmlReporterHelpers.addHelpers(jasmine.HtmlReporter.ReporterView);
-
-
-jasmine.HtmlReporter.SpecView = function(spec, dom, views) {
- this.spec = spec;
- this.dom = dom;
- this.views = views;
-
- this.symbol = this.createDom('li', { className: 'pending' });
- this.dom.symbolSummary.appendChild(this.symbol);
-
- this.summary = this.createDom('div', { className: 'specSummary' },
- this.createDom('a', {
- className: 'description',
- href: jasmine.HtmlReporter.sectionLink(this.spec.getFullName()),
- title: this.spec.getFullName()
- }, this.spec.description)
- );
-
- this.detail = this.createDom('div', { className: 'specDetail' },
- this.createDom('a', {
- className: 'description',
- href: '?spec=' + encodeURIComponent(this.spec.getFullName()),
- title: this.spec.getFullName()
- }, this.spec.getFullName())
- );
-};
-
-jasmine.HtmlReporter.SpecView.prototype.status = function() {
- return this.getSpecStatus(this.spec);
-};
-
-jasmine.HtmlReporter.SpecView.prototype.refresh = function() {
- this.symbol.className = this.status();
-
- switch (this.status()) {
- case 'skipped':
- break;
-
- case 'passed':
- this.appendSummaryToSuiteDiv();
- break;
-
- case 'failed':
- this.appendSummaryToSuiteDiv();
- this.appendFailureDetail();
- break;
}
-};
-jasmine.HtmlReporter.SpecView.prototype.appendSummaryToSuiteDiv = function() {
- this.summary.className += ' ' + this.status();
- this.appendToSummary(this.spec, this.summary);
+ return HtmlReporter;
};
-jasmine.HtmlReporter.SpecView.prototype.appendFailureDetail = function() {
- this.detail.className += ' ' + this.status();
-
- var resultItems = this.spec.results().getItems();
- var messagesDiv = this.createDom('div', { className: 'messages' });
-
- for (var i = 0; i < resultItems.length; i++) {
- var result = resultItems[i];
+jasmineRequire.HtmlSpecFilter = function() {
+ function HtmlSpecFilter(options) {
+ var filterString = options && options.filterString() && options.filterString().replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&');
+ var filterPattern = new RegExp(filterString);
- if (result.type == 'log') {
- messagesDiv.appendChild(this.createDom('div', {className: 'resultMessage log'}, result.toString()));
- } else if (result.type == 'expect' && result.passed && !result.passed()) {
- messagesDiv.appendChild(this.createDom('div', {className: 'resultMessage fail'}, result.message));
-
- if (result.trace.stack) {
- messagesDiv.appendChild(this.createDom('div', {className: 'stackTrace'}, result.trace.stack));
- }
- }
+ this.matches = function(specName) {
+ return filterPattern.test(specName);
+ };
}
- if (messagesDiv.childNodes.length > 0) {
- this.detail.appendChild(messagesDiv);
- this.dom.details.appendChild(this.detail);
- }
+ return HtmlSpecFilter;
};
-jasmine.HtmlReporterHelpers.addHelpers(jasmine.HtmlReporter.SpecView);jasmine.HtmlReporter.SuiteView = function(suite, dom, views) {
- this.suite = suite;
- this.dom = dom;
- this.views = views;
-
- this.element = this.createDom('div', { className: 'suite' },
- this.createDom('a', { className: 'description', href: jasmine.HtmlReporter.sectionLink(this.suite.getFullName()) }, this.suite.description)
- );
+jasmineRequire.ResultsNode = function() {
+ function ResultsNode(result, type, parent) {
+ this.result = result;
+ this.type = type;
+ this.parent = parent;
- this.appendToSummary(this.suite, this.element);
-};
-
-jasmine.HtmlReporter.SuiteView.prototype.status = function() {
- return this.getSpecStatus(this.suite);
-};
+ this.children = [];
-jasmine.HtmlReporter.SuiteView.prototype.refresh = function() {
- this.element.className += " " + this.status();
-};
-
-jasmine.HtmlReporterHelpers.addHelpers(jasmine.HtmlReporter.SuiteView);
-
-/* @deprecated Use jasmine.HtmlReporter instead
- */
-jasmine.TrivialReporter = function(doc) {
- this.document = doc || document;
- this.suiteDivs = {};
- this.logRunningSpecs = false;
-};
-
-jasmine.TrivialReporter.prototype.createDom = function(type, attrs, childrenVarArgs) {
- var el = document.createElement(type);
-
- for (var i = 2; i < arguments.length; i++) {
- var child = arguments[i];
-
- if (typeof child === 'string') {
- el.appendChild(document.createTextNode(child));
- } else {
- if (child) { el.appendChild(child); }
- }
- }
+ this.addChild = function(result, type) {
+ this.children.push(new ResultsNode(result, type, this));
+ };
- for (var attr in attrs) {
- if (attr == "className") {
- el[attr] = attrs[attr];
- } else {
- el.setAttribute(attr, attrs[attr]);
- }
+ this.last = function() {
+ return this.children[this.children.length - 1];
+ };
}
- return el;
+ return ResultsNode;
};
-jasmine.TrivialReporter.prototype.reportRunnerStarting = function(runner) {
- var showPassed, showSkipped;
-
- this.outerDiv = this.createDom('div', { id: 'TrivialReporter', className: 'jasmine_reporter' },
- this.createDom('div', { className: 'banner' },
- this.createDom('div', { className: 'logo' },
- this.createDom('span', { className: 'title' }, "Jasmine"),
- this.createDom('span', { className: 'version' }, runner.env.versionString())),
- this.createDom('div', { className: 'options' },
- "Show ",
- showPassed = this.createDom('input', { id: "__jasmine_TrivialReporter_showPassed__", type: 'checkbox' }),
- this.createDom('label', { "for": "__jasmine_TrivialReporter_showPassed__" }, " passed "),
- showSkipped = this.createDom('input', { id: "__jasmine_TrivialReporter_showSkipped__", type: 'checkbox' }),
- this.createDom('label', { "for": "__jasmine_TrivialReporter_showSkipped__" }, " skipped")
- )
- ),
-
- this.runnerDiv = this.createDom('div', { className: 'runner running' },
- this.createDom('a', { className: 'run_spec', href: '?' }, "run all"),
- this.runnerMessageSpan = this.createDom('span', {}, "Running..."),
- this.finishedAtSpan = this.createDom('span', { className: 'finished-at' }, ""))
- );
-
- this.document.body.appendChild(this.outerDiv);
-
- var suites = runner.suites();
- for (var i = 0; i < suites.length; i++) {
- var suite = suites[i];
- var suiteDiv = this.createDom('div', { className: 'suite' },
- this.createDom('a', { className: 'run_spec', href: '?spec=' + encodeURIComponent(suite.getFullName()) }, "run"),
- this.createDom('a', { className: 'description', href: '?spec=' + encodeURIComponent(suite.getFullName()) }, suite.description));
- this.suiteDivs[suite.id] = suiteDiv;
- var parentDiv = this.outerDiv;
- if (suite.parentSuite) {
- parentDiv = this.suiteDivs[suite.parentSuite.id];
- }
- parentDiv.appendChild(suiteDiv);
- }
-
- this.startedAt = new Date();
-
- var self = this;
- showPassed.onclick = function(evt) {
- if (showPassed.checked) {
- self.outerDiv.className += ' show-passed';
- } else {
- self.outerDiv.className = self.outerDiv.className.replace(/ show-passed/, '');
- }
- };
-
- showSkipped.onclick = function(evt) {
- if (showSkipped.checked) {
- self.outerDiv.className += ' show-skipped';
- } else {
- self.outerDiv.className = self.outerDiv.className.replace(/ show-skipped/, '');
- }
- };
-};
+jasmineRequire.QueryString = function() {
+ function QueryString(options) {
-jasmine.TrivialReporter.prototype.reportRunnerResults = function(runner) {
- var results = runner.results();
- var className = (results.failedCount > 0) ? "runner failed" : "runner passed";
- this.runnerDiv.setAttribute("class", className);
- //do it twice for IE
- this.runnerDiv.setAttribute("className", className);
- var specs = runner.specs();
- var specCount = 0;
- for (var i = 0; i < specs.length; i++) {
- if (this.specFilter(specs[i])) {
- specCount++;
- }
- }
- var message = "" + specCount + " spec" + (specCount == 1 ? "" : "s" ) + ", " + results.failedCount + " failure" + ((results.failedCount == 1) ? "" : "s");
- message += " in " + ((new Date().getTime() - this.startedAt.getTime()) / 1000) + "s";
- this.runnerMessageSpan.replaceChild(this.createDom('a', { className: 'description', href: '?'}, message), this.runnerMessageSpan.firstChild);
-
- this.finishedAtSpan.appendChild(document.createTextNode("Finished at " + new Date().toString()));
-};
+ this.setParam = function(key, value) {
+ var paramMap = queryStringToParamMap();
+ paramMap[key] = value;
+ options.getWindowLocation().search = toQueryString(paramMap);
+ };
-jasmine.TrivialReporter.prototype.reportSuiteResults = function(suite) {
- var results = suite.results();
- var status = results.passed() ? 'passed' : 'failed';
- if (results.totalCount === 0) { // todo: change this to check results.skipped
- status = 'skipped';
- }
- this.suiteDivs[suite.id].className += " " + status;
-};
+ this.getParam = function(key) {
+ return queryStringToParamMap()[key];
+ };
-jasmine.TrivialReporter.prototype.reportSpecStarting = function(spec) {
- if (this.logRunningSpecs) {
- this.log('>> Jasmine Running ' + spec.suite.description + ' ' + spec.description + '...');
- }
-};
+ return this;
-jasmine.TrivialReporter.prototype.reportSpecResults = function(spec) {
- var results = spec.results();
- var status = results.passed() ? 'passed' : 'failed';
- if (results.skipped) {
- status = 'skipped';
- }
- var specDiv = this.createDom('div', { className: 'spec ' + status },
- this.createDom('a', { className: 'run_spec', href: '?spec=' + encodeURIComponent(spec.getFullName()) }, "run"),
- this.createDom('a', {
- className: 'description',
- href: '?spec=' + encodeURIComponent(spec.getFullName()),
- title: spec.getFullName()
- }, spec.description));
-
-
- var resultItems = results.getItems();
- var messagesDiv = this.createDom('div', { className: 'messages' });
- for (var i = 0; i < resultItems.length; i++) {
- var result = resultItems[i];
-
- if (result.type == 'log') {
- messagesDiv.appendChild(this.createDom('div', {className: 'resultMessage log'}, result.toString()));
- } else if (result.type == 'expect' && result.passed && !result.passed()) {
- messagesDiv.appendChild(this.createDom('div', {className: 'resultMessage fail'}, result.message));
-
- if (result.trace.stack) {
- messagesDiv.appendChild(this.createDom('div', {className: 'stackTrace'}, result.trace.stack));
+ function toQueryString(paramMap) {
+ var qStrPairs = [];
+ for (var prop in paramMap) {
+ qStrPairs.push(encodeURIComponent(prop) + '=' + encodeURIComponent(paramMap[prop]));
+ }
+ return '?' + qStrPairs.join('&');
+ }
+
+ function queryStringToParamMap() {
+ var paramStr = options.getWindowLocation().search.substring(1),
+ params = [],
+ paramMap = {};
+
+ if (paramStr.length > 0) {
+ params = paramStr.split('&');
+ for (var i = 0; i < params.length; i++) {
+ var p = params[i].split('=');
+ var value = decodeURIComponent(p[1]);
+ if (value === 'true' || value === 'false') {
+ value = JSON.parse(value);
+ }
+ paramMap[decodeURIComponent(p[0])] = value;
+ }
}
- }
- }
-
- if (messagesDiv.childNodes.length > 0) {
- specDiv.appendChild(messagesDiv);
- }
-
- this.suiteDivs[spec.suite.id].appendChild(specDiv);
-};
-jasmine.TrivialReporter.prototype.log = function() {
- var console = jasmine.getGlobal().console;
- if (console && console.log) {
- if (console.log.apply) {
- console.log.apply(console, arguments);
- } else {
- console.log(arguments); // ie fix: console.log.apply doesn't exist on ie
+ return paramMap;
}
- }
-};
-jasmine.TrivialReporter.prototype.getLocation = function() {
- return this.document.location;
-};
-
-jasmine.TrivialReporter.prototype.specFilter = function(spec) {
- var paramMap = {};
- var params = this.getLocation().search.substring(1).split('&');
- for (var i = 0; i < params.length; i++) {
- var p = params[i].split('=');
- paramMap[decodeURIComponent(p[0])] = decodeURIComponent(p[1]);
}
- if (!paramMap.spec) {
- return true;
- }
- return spec.getFullName().indexOf(paramMap.spec) === 0;
+ return QueryString;
};