Remove results from Queue
- consequently, Runner & Suite no longer have results. - Results come back to reporters from Spec, we should not have a need to walk them later via suite/runner (in fact, no reporter used results on suite/runner -- only bad tests) - Remove/clean up tests relying on #results - Remove integration tests that duplicate already tested behavior
This commit is contained in:
@@ -1,54 +0,0 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
|
||||||
"http://www.w3.org/TR/html4/loose.dtd">
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<title>Jasmine Spec Runner</title>
|
|
||||||
|
|
||||||
<link rel="shortcut icon" type="image/png" href="lib/jasmine-1.1.0.rc1/jasmine_favicon.png">
|
|
||||||
|
|
||||||
<link rel="stylesheet" type="text/css" href="lib/jasmine-1.1.0.rc1/jasmine.css">
|
|
||||||
<script type="text/javascript" src="lib/jasmine-1.1.0.rc1/jasmine.js"></script>
|
|
||||||
<script type="text/javascript" src="lib/jasmine-1.1.0.rc1/jasmine-html.js"></script>
|
|
||||||
|
|
||||||
<!-- include spec files here... -->
|
|
||||||
<script type="text/javascript" src="spec/SpecHelper.js"></script>
|
|
||||||
<script type="text/javascript" src="spec/PlayerSpec.js"></script>
|
|
||||||
|
|
||||||
<!-- include source files here... -->
|
|
||||||
<script type="text/javascript" src="src/Player.js"></script>
|
|
||||||
<script type="text/javascript" src="src/Song.js"></script>
|
|
||||||
|
|
||||||
<script type="text/javascript">
|
|
||||||
(function() {
|
|
||||||
var jasmineEnv = jasmine.getEnv();
|
|
||||||
jasmineEnv.updateInterval = 1000;
|
|
||||||
|
|
||||||
var trivialReporter = new jasmine.TrivialReporter();
|
|
||||||
|
|
||||||
jasmineEnv.addReporter(trivialReporter);
|
|
||||||
|
|
||||||
jasmineEnv.specFilter = function(spec) {
|
|
||||||
return trivialReporter.specFilter(spec);
|
|
||||||
};
|
|
||||||
|
|
||||||
var currentWindowOnload = window.onload;
|
|
||||||
|
|
||||||
window.onload = function() {
|
|
||||||
if (currentWindowOnload) {
|
|
||||||
currentWindowOnload();
|
|
||||||
}
|
|
||||||
execJasmine();
|
|
||||||
};
|
|
||||||
|
|
||||||
function execJasmine() {
|
|
||||||
jasmineEnv.execute();
|
|
||||||
}
|
|
||||||
|
|
||||||
})();
|
|
||||||
</script>
|
|
||||||
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -27,6 +27,9 @@ jasmine.HtmlReporterHelpers.createDom = function(type, attrs, childrenVarArgs) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
jasmine.HtmlReporterHelpers.getSpecStatus = function(child) {
|
jasmine.HtmlReporterHelpers.getSpecStatus = function(child) {
|
||||||
|
if (!child.results) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
var results = child.results();
|
var results = child.results();
|
||||||
var status = results.passed() ? 'passed' : 'failed';
|
var status = results.passed() ? 'passed' : 'failed';
|
||||||
if (results.skipped) {
|
if (results.skipped) {
|
||||||
@@ -488,195 +491,3 @@ jasmine.HtmlReporter.SuiteView.prototype.refresh = function() {
|
|||||||
|
|
||||||
jasmine.HtmlReporterHelpers.addHelpers(jasmine.HtmlReporter.SuiteView);
|
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); }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (var attr in attrs) {
|
|
||||||
if (attr == "className") {
|
|
||||||
el[attr] = attrs[attr];
|
|
||||||
} else {
|
|
||||||
el.setAttribute(attr, attrs[attr]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return el;
|
|
||||||
};
|
|
||||||
|
|
||||||
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/, '');
|
|
||||||
}
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
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()));
|
|
||||||
};
|
|
||||||
|
|
||||||
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;
|
|
||||||
};
|
|
||||||
|
|
||||||
jasmine.TrivialReporter.prototype.reportSpecStarting = function(spec) {
|
|
||||||
if (this.logRunningSpecs) {
|
|
||||||
this.log('>> Jasmine Running ' + spec.suite.description + ' ' + spec.description + '...');
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
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) {
|
|
||||||
messagesDiv.appendChild(this.createDom('div', {className: 'resultMessage fail'}, result.message));
|
|
||||||
|
|
||||||
if (result.trace.stack) {
|
|
||||||
messagesDiv.appendChild(this.createDom('div', {className: 'stackTrace'}, result.trace.stack));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
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;
|
|
||||||
};
|
|
||||||
|
|||||||
@@ -50,33 +50,3 @@ body { background-color: #eeeeee; padding: 0; margin: 5px; overflow-y: scroll; }
|
|||||||
#HTMLReporter .resultMessage { padding-top: 14px; color: #333333; }
|
#HTMLReporter .resultMessage { padding-top: 14px; color: #333333; }
|
||||||
#HTMLReporter .resultMessage span.result { display: block; }
|
#HTMLReporter .resultMessage span.result { display: block; }
|
||||||
#HTMLReporter .stackTrace { margin: 5px 0 0 0; max-height: 224px; overflow: auto; line-height: 18px; color: #666666; border: 1px solid #ddd; background: white; white-space: pre; }
|
#HTMLReporter .stackTrace { margin: 5px 0 0 0; max-height: 224px; overflow: auto; line-height: 18px; color: #666666; border: 1px solid #ddd; background: white; white-space: pre; }
|
||||||
|
|
||||||
#TrivialReporter { padding: 8px 13px; position: absolute; top: 0; bottom: 0; left: 0; right: 0; overflow-y: scroll; background-color: white; font-family: "Helvetica Neue Light", "Lucida Grande", "Calibri", "Arial", sans-serif; /*.resultMessage {*/ /*white-space: pre;*/ /*}*/ }
|
|
||||||
#TrivialReporter a:visited, #TrivialReporter a { color: #303; }
|
|
||||||
#TrivialReporter a:hover, #TrivialReporter a:active { color: blue; }
|
|
||||||
#TrivialReporter .run_spec { float: right; padding-right: 5px; font-size: .8em; text-decoration: none; }
|
|
||||||
#TrivialReporter .banner { color: #303; background-color: #fef; padding: 5px; }
|
|
||||||
#TrivialReporter .logo { float: left; font-size: 1.1em; padding-left: 5px; }
|
|
||||||
#TrivialReporter .logo .version { font-size: .6em; padding-left: 1em; }
|
|
||||||
#TrivialReporter .runner.running { background-color: yellow; }
|
|
||||||
#TrivialReporter .options { text-align: right; font-size: .8em; }
|
|
||||||
#TrivialReporter .suite { border: 1px outset gray; margin: 5px 0; padding-left: 1em; }
|
|
||||||
#TrivialReporter .suite .suite { margin: 5px; }
|
|
||||||
#TrivialReporter .suite.passed { background-color: #dfd; }
|
|
||||||
#TrivialReporter .suite.failed { background-color: #fdd; }
|
|
||||||
#TrivialReporter .spec { margin: 5px; padding-left: 1em; clear: both; }
|
|
||||||
#TrivialReporter .spec.failed, #TrivialReporter .spec.passed, #TrivialReporter .spec.skipped { padding-bottom: 5px; border: 1px solid gray; }
|
|
||||||
#TrivialReporter .spec.failed { background-color: #fbb; border-color: red; }
|
|
||||||
#TrivialReporter .spec.passed { background-color: #bfb; border-color: green; }
|
|
||||||
#TrivialReporter .spec.skipped { background-color: #bbb; }
|
|
||||||
#TrivialReporter .messages { border-left: 1px dashed gray; padding-left: 1em; padding-right: 1em; }
|
|
||||||
#TrivialReporter .passed { background-color: #cfc; display: none; }
|
|
||||||
#TrivialReporter .failed { background-color: #fbb; }
|
|
||||||
#TrivialReporter .skipped { color: #777; background-color: #eee; display: none; }
|
|
||||||
#TrivialReporter .resultMessage span.result { display: block; line-height: 2em; color: black; }
|
|
||||||
#TrivialReporter .resultMessage .mismatch { color: black; }
|
|
||||||
#TrivialReporter .stackTrace { white-space: pre; font-size: .8em; margin-left: 10px; max-height: 5em; overflow: auto; border: 1px inset red; padding: 1em; background: #eef; }
|
|
||||||
#TrivialReporter .finished-at { padding-left: 1em; font-size: .6em; }
|
|
||||||
#TrivialReporter.show-passed .passed, #TrivialReporter.show-skipped .skipped { display: block; }
|
|
||||||
#TrivialReporter #jasmine_content { position: fixed; right: 100%; }
|
|
||||||
#TrivialReporter .runner { border: 1px solid gray; display: block; margin: 5px 0; padding: 2px 0 2px 10px; }
|
|
||||||
|
|||||||
+285
-309
@@ -510,15 +510,13 @@ jasmine.util.extend = function(destination, source) {
|
|||||||
|
|
||||||
//TODO: expectation result may make more sense as a presentation of an expectation.
|
//TODO: expectation result may make more sense as a presentation of an expectation.
|
||||||
jasmine.buildExpectationResult = function(params) {
|
jasmine.buildExpectationResult = function(params) {
|
||||||
var trace = (params.trace || new Error(this.message));
|
|
||||||
var message = params.passed ? 'Passed.' : params.message;
|
|
||||||
return {
|
return {
|
||||||
type: 'expect',
|
type: 'expect',
|
||||||
matcherName: params.matcherName,
|
matcherName: params.matcherName,
|
||||||
expected: params.expected,
|
expected: params.expected,
|
||||||
actual: params.actual,
|
actual: params.actual,
|
||||||
message: message,
|
message: params.passed ? 'Passed.' : params.message,
|
||||||
trace: params.passed ? '' : trace,
|
trace: params.passed ? '' : (params.trace || new Error(this.message)),
|
||||||
passed: params.passed
|
passed: params.passed
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@@ -527,301 +525,308 @@ jasmine.buildExpectationResult = function(params) {
|
|||||||
*
|
*
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
jasmine.Env = function() {
|
(function() {
|
||||||
this.currentSpec = null;
|
|
||||||
this.currentSuite = null;
|
|
||||||
this.currentRunner_ = new jasmine.Runner(this);
|
|
||||||
|
|
||||||
this.reporter = new jasmine.MultiReporter();
|
function createSpec(env, suite, description) {
|
||||||
|
return new jasmine.Spec(env, suite, description);
|
||||||
|
}
|
||||||
|
|
||||||
this.updateInterval = jasmine.DEFAULT_UPDATE_INTERVAL;
|
jasmine.Env = function() {
|
||||||
this.defaultTimeoutInterval = jasmine.DEFAULT_TIMEOUT_INTERVAL;
|
this.currentSpec = null;
|
||||||
this.lastUpdate = 0;
|
this.currentSuite = null;
|
||||||
this.specFilter = function() {
|
this.currentRunner_ = new jasmine.Runner(this);
|
||||||
return true;
|
|
||||||
|
this.reporter = new jasmine.MultiReporter();
|
||||||
|
|
||||||
|
this.updateInterval = jasmine.DEFAULT_UPDATE_INTERVAL;
|
||||||
|
this.defaultTimeoutInterval = jasmine.DEFAULT_TIMEOUT_INTERVAL;
|
||||||
|
this.lastUpdate = 0;
|
||||||
|
this.specFilter = function() {
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
|
||||||
|
this.nextSpecId_ = 0;
|
||||||
|
this.nextSuiteId_ = 0;
|
||||||
|
this.equalityTesters_ = [];
|
||||||
|
|
||||||
|
// wrap matchers
|
||||||
|
this.matchersClass = function() {
|
||||||
|
jasmine.Matchers.apply(this, arguments);
|
||||||
|
};
|
||||||
|
jasmine.util.inherit(this.matchersClass, jasmine.Matchers);
|
||||||
|
|
||||||
|
jasmine.Matchers.wrapInto_(jasmine.Matchers.prototype, this.matchersClass);
|
||||||
};
|
};
|
||||||
|
|
||||||
this.nextSpecId_ = 0;
|
|
||||||
this.nextSuiteId_ = 0;
|
|
||||||
this.equalityTesters_ = [];
|
|
||||||
|
|
||||||
// wrap matchers
|
jasmine.Env.prototype.setTimeout = jasmine.setTimeout;
|
||||||
this.matchersClass = function() {
|
jasmine.Env.prototype.clearTimeout = jasmine.clearTimeout;
|
||||||
jasmine.Matchers.apply(this, arguments);
|
jasmine.Env.prototype.setInterval = jasmine.setInterval;
|
||||||
};
|
jasmine.Env.prototype.clearInterval = jasmine.clearInterval;
|
||||||
jasmine.util.inherit(this.matchersClass, jasmine.Matchers);
|
|
||||||
|
|
||||||
jasmine.Matchers.wrapInto_(jasmine.Matchers.prototype, this.matchersClass);
|
/**
|
||||||
};
|
* @returns an object containing jasmine version build info, if set.
|
||||||
|
*/
|
||||||
|
jasmine.Env.prototype.version = function () {
|
||||||
jasmine.Env.prototype.setTimeout = jasmine.setTimeout;
|
if (jasmine.version_) {
|
||||||
jasmine.Env.prototype.clearTimeout = jasmine.clearTimeout;
|
return jasmine.version_;
|
||||||
jasmine.Env.prototype.setInterval = jasmine.setInterval;
|
} else {
|
||||||
jasmine.Env.prototype.clearInterval = jasmine.clearInterval;
|
throw new Error('Version not set');
|
||||||
|
|
||||||
/**
|
|
||||||
* @returns an object containing jasmine version build info, if set.
|
|
||||||
*/
|
|
||||||
jasmine.Env.prototype.version = function () {
|
|
||||||
if (jasmine.version_) {
|
|
||||||
return jasmine.version_;
|
|
||||||
} else {
|
|
||||||
throw new Error('Version not set');
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @returns string containing jasmine version build info, if set.
|
|
||||||
*/
|
|
||||||
jasmine.Env.prototype.versionString = function() {
|
|
||||||
if (!jasmine.version_) {
|
|
||||||
return "version unknown";
|
|
||||||
}
|
|
||||||
|
|
||||||
var version = this.version();
|
|
||||||
var versionString = version.major + "." + version.minor + "." + version.build;
|
|
||||||
if (version.release_candidate) {
|
|
||||||
versionString += ".rc" + version.release_candidate;
|
|
||||||
}
|
|
||||||
versionString += " revision " + version.revision;
|
|
||||||
return versionString;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @returns a sequential integer starting at 0
|
|
||||||
*/
|
|
||||||
jasmine.Env.prototype.nextSpecId = function () {
|
|
||||||
return this.nextSpecId_++;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @returns a sequential integer starting at 0
|
|
||||||
*/
|
|
||||||
jasmine.Env.prototype.nextSuiteId = function () {
|
|
||||||
return this.nextSuiteId_++;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Register a reporter to receive status updates from Jasmine.
|
|
||||||
* @param {jasmine.Reporter} reporter An object which will receive status updates.
|
|
||||||
*/
|
|
||||||
jasmine.Env.prototype.addReporter = function(reporter) {
|
|
||||||
this.reporter.addReporter(reporter);
|
|
||||||
};
|
|
||||||
|
|
||||||
jasmine.Env.prototype.execute = function() {
|
|
||||||
this.currentRunner_.execute();
|
|
||||||
};
|
|
||||||
|
|
||||||
jasmine.Env.prototype.describe = function(description, specDefinitions) {
|
|
||||||
var suite = new jasmine.Suite(this, description, specDefinitions, this.currentSuite);
|
|
||||||
|
|
||||||
var parentSuite = this.currentSuite;
|
|
||||||
if (parentSuite) {
|
|
||||||
parentSuite.add(suite);
|
|
||||||
} else {
|
|
||||||
this.currentRunner_.add(suite);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.currentSuite = suite;
|
|
||||||
|
|
||||||
var declarationError = null;
|
|
||||||
try {
|
|
||||||
specDefinitions.call(suite);
|
|
||||||
} catch(e) {
|
|
||||||
declarationError = e;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (declarationError) {
|
|
||||||
this.it("encountered a declaration exception", function() {
|
|
||||||
throw declarationError;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
this.currentSuite = parentSuite;
|
|
||||||
|
|
||||||
return suite;
|
|
||||||
};
|
|
||||||
|
|
||||||
jasmine.Env.prototype.beforeEach = function(beforeEachFunction) {
|
|
||||||
if (this.currentSuite) {
|
|
||||||
this.currentSuite.beforeEach(beforeEachFunction);
|
|
||||||
} else {
|
|
||||||
this.currentRunner_.beforeEach(beforeEachFunction);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
jasmine.Env.prototype.currentRunner = function () {
|
|
||||||
return this.currentRunner_;
|
|
||||||
};
|
|
||||||
|
|
||||||
jasmine.Env.prototype.afterEach = function(afterEachFunction) {
|
|
||||||
if (this.currentSuite) {
|
|
||||||
this.currentSuite.afterEach(afterEachFunction);
|
|
||||||
} else {
|
|
||||||
this.currentRunner_.afterEach(afterEachFunction);
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
jasmine.Env.prototype.xdescribe = function(desc, specDefinitions) {
|
|
||||||
return {
|
|
||||||
execute: function() {
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
|
||||||
|
|
||||||
jasmine.Env.prototype.it = function(description, func) {
|
/**
|
||||||
var spec = new jasmine.Spec(this, this.currentSuite, description);
|
* @returns string containing jasmine version build info, if set.
|
||||||
this.currentSuite.add(spec);
|
*/
|
||||||
this.currentSpec = spec;
|
jasmine.Env.prototype.versionString = function() {
|
||||||
|
if (!jasmine.version_) {
|
||||||
if (func) {
|
return "version unknown";
|
||||||
spec.runs(func);
|
|
||||||
}
|
|
||||||
|
|
||||||
return spec;
|
|
||||||
};
|
|
||||||
|
|
||||||
jasmine.Env.prototype.xit = function(desc, func) {
|
|
||||||
return {
|
|
||||||
id: this.nextSpecId(),
|
|
||||||
runs: function() {
|
|
||||||
}
|
}
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
jasmine.Env.prototype.compareRegExps_ = function(a, b, mismatchKeys, mismatchValues) {
|
var version = this.version();
|
||||||
if (a.source != b.source)
|
var versionString = version.major + "." + version.minor + "." + version.build;
|
||||||
mismatchValues.push("expected pattern /" + b.source + "/ is not equal to the pattern /" + a.source + "/");
|
if (version.release_candidate) {
|
||||||
|
versionString += ".rc" + version.release_candidate;
|
||||||
if (a.ignoreCase != b.ignoreCase)
|
}
|
||||||
mismatchValues.push("expected modifier i was" + (b.ignoreCase ? " " : " not ") + "set and does not equal the origin modifier");
|
versionString += " revision " + version.revision;
|
||||||
|
return versionString;
|
||||||
if (a.global != b.global)
|
|
||||||
mismatchValues.push("expected modifier g was" + (b.global ? " " : " not ") + "set and does not equal the origin modifier");
|
|
||||||
|
|
||||||
if (a.multiline != b.multiline)
|
|
||||||
mismatchValues.push("expected modifier m was" + (b.multiline ? " " : " not ") + "set and does not equal the origin modifier");
|
|
||||||
|
|
||||||
if (a.sticky != b.sticky)
|
|
||||||
mismatchValues.push("expected modifier y was" + (b.sticky ? " " : " not ") + "set and does not equal the origin modifier");
|
|
||||||
|
|
||||||
return (mismatchValues.length === 0);
|
|
||||||
};
|
|
||||||
|
|
||||||
jasmine.Env.prototype.compareObjects_ = function(a, b, mismatchKeys, mismatchValues) {
|
|
||||||
if (a.__Jasmine_been_here_before__ === b && b.__Jasmine_been_here_before__ === a) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
a.__Jasmine_been_here_before__ = b;
|
|
||||||
b.__Jasmine_been_here_before__ = a;
|
|
||||||
|
|
||||||
var hasKey = function(obj, keyName) {
|
|
||||||
return obj !== null && obj[keyName] !== jasmine.undefined;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
for (var property in b) {
|
/**
|
||||||
if (!hasKey(a, property) && hasKey(b, property)) {
|
* @returns a sequential integer starting at 0
|
||||||
mismatchKeys.push("expected has key '" + property + "', but missing from actual.");
|
*/
|
||||||
|
jasmine.Env.prototype.nextSpecId = function () {
|
||||||
|
return this.nextSpecId_++;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @returns a sequential integer starting at 0
|
||||||
|
*/
|
||||||
|
jasmine.Env.prototype.nextSuiteId = function () {
|
||||||
|
return this.nextSuiteId_++;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register a reporter to receive status updates from Jasmine.
|
||||||
|
* @param {jasmine.Reporter} reporter An object which will receive status updates.
|
||||||
|
*/
|
||||||
|
jasmine.Env.prototype.addReporter = function(reporter) {
|
||||||
|
this.reporter.addReporter(reporter);
|
||||||
|
};
|
||||||
|
|
||||||
|
jasmine.Env.prototype.execute = function() {
|
||||||
|
this.currentRunner_.execute();
|
||||||
|
};
|
||||||
|
|
||||||
|
jasmine.Env.prototype.describe = function(description, specDefinitions) {
|
||||||
|
var suite = new jasmine.Suite(this, description, specDefinitions, this.currentSuite);
|
||||||
|
|
||||||
|
var parentSuite = this.currentSuite;
|
||||||
|
if (parentSuite) {
|
||||||
|
parentSuite.add(suite);
|
||||||
|
} else {
|
||||||
|
this.currentRunner_.add(suite);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
for (property in a) {
|
this.currentSuite = suite;
|
||||||
if (!hasKey(b, property) && hasKey(a, property)) {
|
|
||||||
mismatchKeys.push("expected missing key '" + property + "', but present in actual.");
|
var declarationError = null;
|
||||||
|
try {
|
||||||
|
specDefinitions.call(suite);
|
||||||
|
} catch(e) {
|
||||||
|
declarationError = e;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
for (property in b) {
|
if (declarationError) {
|
||||||
if (property == '__Jasmine_been_here_before__') continue;
|
this.it("encountered a declaration exception", function() {
|
||||||
if (!this.equals_(a[property], b[property], mismatchKeys, mismatchValues)) {
|
throw declarationError;
|
||||||
mismatchValues.push("'" + property + "' was '" + (b[property] ? jasmine.util.htmlEscape(b[property].toString()) : b[property]) + "' in expected, but was '" + (a[property] ? jasmine.util.htmlEscape(a[property].toString()) : a[property]) + "' in actual.");
|
});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (jasmine.isArray_(a) && jasmine.isArray_(b) && a.length != b.length) {
|
this.currentSuite = parentSuite;
|
||||||
mismatchValues.push("arrays were not the same length");
|
|
||||||
}
|
|
||||||
|
|
||||||
delete a.__Jasmine_been_here_before__;
|
return suite;
|
||||||
delete b.__Jasmine_been_here_before__;
|
};
|
||||||
return (mismatchKeys.length === 0 && mismatchValues.length === 0);
|
|
||||||
};
|
|
||||||
|
|
||||||
jasmine.Env.prototype.equals_ = function(a, b, mismatchKeys, mismatchValues) {
|
jasmine.Env.prototype.beforeEach = function(beforeEachFunction) {
|
||||||
mismatchKeys = mismatchKeys || [];
|
if (this.currentSuite) {
|
||||||
mismatchValues = mismatchValues || [];
|
this.currentSuite.beforeEach(beforeEachFunction);
|
||||||
|
} else {
|
||||||
for (var i = 0; i < this.equalityTesters_.length; i++) {
|
this.currentRunner_.beforeEach(beforeEachFunction);
|
||||||
var equalityTester = this.equalityTesters_[i];
|
|
||||||
var result = equalityTester(a, b, this, mismatchKeys, mismatchValues);
|
|
||||||
if (result !== jasmine.undefined) return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (a === b) return true;
|
|
||||||
|
|
||||||
if (a === jasmine.undefined || a === null || b === jasmine.undefined || b === null) {
|
|
||||||
return (a == jasmine.undefined && b == jasmine.undefined);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (jasmine.isDomNode(a) && jasmine.isDomNode(b)) {
|
|
||||||
return a === b;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (a instanceof Date && b instanceof Date) {
|
|
||||||
return a.getTime() == b.getTime();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (a.jasmineMatches) {
|
|
||||||
return a.jasmineMatches(b);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (b.jasmineMatches) {
|
|
||||||
return b.jasmineMatches(a);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (a instanceof jasmine.Matchers.ObjectContaining) {
|
|
||||||
return a.matches(b);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (b instanceof jasmine.Matchers.ObjectContaining) {
|
|
||||||
return b.matches(a);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (jasmine.isString_(a) && jasmine.isString_(b)) {
|
|
||||||
return (a == b);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (jasmine.isNumber_(a) && jasmine.isNumber_(b)) {
|
|
||||||
return (a == b);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (a instanceof RegExp && b instanceof RegExp) {
|
|
||||||
return this.compareRegExps_(a, b, mismatchKeys, mismatchValues);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (typeof a === "object" && typeof b === "object") {
|
|
||||||
return this.compareObjects_(a, b, mismatchKeys, mismatchValues);
|
|
||||||
}
|
|
||||||
|
|
||||||
//Straight check
|
|
||||||
return (a === b);
|
|
||||||
};
|
|
||||||
|
|
||||||
jasmine.Env.prototype.contains_ = function(haystack, needle) {
|
|
||||||
if (jasmine.isArray_(haystack)) {
|
|
||||||
for (var i = 0; i < haystack.length; i++) {
|
|
||||||
if (this.equals_(haystack[i], needle)) return true;
|
|
||||||
}
|
}
|
||||||
return false;
|
};
|
||||||
}
|
|
||||||
return haystack.indexOf(needle) >= 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
jasmine.Env.prototype.addEqualityTester = function(equalityTester) {
|
jasmine.Env.prototype.currentRunner = function () {
|
||||||
this.equalityTesters_.push(equalityTester);
|
return this.currentRunner_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
jasmine.Env.prototype.afterEach = function(afterEachFunction) {
|
||||||
|
if (this.currentSuite) {
|
||||||
|
this.currentSuite.afterEach(afterEachFunction);
|
||||||
|
} else {
|
||||||
|
this.currentRunner_.afterEach(afterEachFunction);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
jasmine.Env.prototype.xdescribe = function(desc, specDefinitions) {
|
||||||
|
return {
|
||||||
|
execute: function() {
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
jasmine.Env.prototype.it = function(description, func) {
|
||||||
|
var spec = createSpec(this, this.currentSuite, description);
|
||||||
|
this.currentSuite.add(spec);
|
||||||
|
this.currentSpec = spec;
|
||||||
|
|
||||||
|
if (func) {
|
||||||
|
spec.runs(func);
|
||||||
|
}
|
||||||
|
|
||||||
|
return spec;
|
||||||
|
};
|
||||||
|
|
||||||
|
jasmine.Env.prototype.xit = function(desc, func) {
|
||||||
|
return {
|
||||||
|
id: this.nextSpecId(),
|
||||||
|
runs: function() {
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
jasmine.Env.prototype.compareRegExps_ = function(a, b, mismatchKeys, mismatchValues) {
|
||||||
|
if (a.source != b.source)
|
||||||
|
mismatchValues.push("expected pattern /" + b.source + "/ is not equal to the pattern /" + a.source + "/");
|
||||||
|
|
||||||
|
if (a.ignoreCase != b.ignoreCase)
|
||||||
|
mismatchValues.push("expected modifier i was" + (b.ignoreCase ? " " : " not ") + "set and does not equal the origin modifier");
|
||||||
|
|
||||||
|
if (a.global != b.global)
|
||||||
|
mismatchValues.push("expected modifier g was" + (b.global ? " " : " not ") + "set and does not equal the origin modifier");
|
||||||
|
|
||||||
|
if (a.multiline != b.multiline)
|
||||||
|
mismatchValues.push("expected modifier m was" + (b.multiline ? " " : " not ") + "set and does not equal the origin modifier");
|
||||||
|
|
||||||
|
if (a.sticky != b.sticky)
|
||||||
|
mismatchValues.push("expected modifier y was" + (b.sticky ? " " : " not ") + "set and does not equal the origin modifier");
|
||||||
|
|
||||||
|
return (mismatchValues.length === 0);
|
||||||
|
};
|
||||||
|
|
||||||
|
jasmine.Env.prototype.compareObjects_ = function(a, b, mismatchKeys, mismatchValues) {
|
||||||
|
if (a.__Jasmine_been_here_before__ === b && b.__Jasmine_been_here_before__ === a) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
a.__Jasmine_been_here_before__ = b;
|
||||||
|
b.__Jasmine_been_here_before__ = a;
|
||||||
|
|
||||||
|
var hasKey = function(obj, keyName) {
|
||||||
|
return obj !== null && obj[keyName] !== jasmine.undefined;
|
||||||
|
};
|
||||||
|
|
||||||
|
for (var property in b) {
|
||||||
|
if (!hasKey(a, property) && hasKey(b, property)) {
|
||||||
|
mismatchKeys.push("expected has key '" + property + "', but missing from actual.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (property in a) {
|
||||||
|
if (!hasKey(b, property) && hasKey(a, property)) {
|
||||||
|
mismatchKeys.push("expected missing key '" + property + "', but present in actual.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (property in b) {
|
||||||
|
if (property == '__Jasmine_been_here_before__') continue;
|
||||||
|
if (!this.equals_(a[property], b[property], mismatchKeys, mismatchValues)) {
|
||||||
|
mismatchValues.push("'" + property + "' was '" + (b[property] ? jasmine.util.htmlEscape(b[property].toString()) : b[property]) + "' in expected, but was '" + (a[property] ? jasmine.util.htmlEscape(a[property].toString()) : a[property]) + "' in actual.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (jasmine.isArray_(a) && jasmine.isArray_(b) && a.length != b.length) {
|
||||||
|
mismatchValues.push("arrays were not the same length");
|
||||||
|
}
|
||||||
|
|
||||||
|
delete a.__Jasmine_been_here_before__;
|
||||||
|
delete b.__Jasmine_been_here_before__;
|
||||||
|
return (mismatchKeys.length === 0 && mismatchValues.length === 0);
|
||||||
|
};
|
||||||
|
|
||||||
|
jasmine.Env.prototype.equals_ = function(a, b, mismatchKeys, mismatchValues) {
|
||||||
|
mismatchKeys = mismatchKeys || [];
|
||||||
|
mismatchValues = mismatchValues || [];
|
||||||
|
|
||||||
|
for (var i = 0; i < this.equalityTesters_.length; i++) {
|
||||||
|
var equalityTester = this.equalityTesters_[i];
|
||||||
|
var result = equalityTester(a, b, this, mismatchKeys, mismatchValues);
|
||||||
|
if (result !== jasmine.undefined) return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (a === b) return true;
|
||||||
|
|
||||||
|
if (a === jasmine.undefined || a === null || b === jasmine.undefined || b === null) {
|
||||||
|
return (a == jasmine.undefined && b == jasmine.undefined);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (jasmine.isDomNode(a) && jasmine.isDomNode(b)) {
|
||||||
|
return a === b;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (a instanceof Date && b instanceof Date) {
|
||||||
|
return a.getTime() == b.getTime();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (a.jasmineMatches) {
|
||||||
|
return a.jasmineMatches(b);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (b.jasmineMatches) {
|
||||||
|
return b.jasmineMatches(a);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (a instanceof jasmine.Matchers.ObjectContaining) {
|
||||||
|
return a.matches(b);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (b instanceof jasmine.Matchers.ObjectContaining) {
|
||||||
|
return b.matches(a);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (jasmine.isString_(a) && jasmine.isString_(b)) {
|
||||||
|
return (a == b);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (jasmine.isNumber_(a) && jasmine.isNumber_(b)) {
|
||||||
|
return (a == b);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (a instanceof RegExp && b instanceof RegExp) {
|
||||||
|
return this.compareRegExps_(a, b, mismatchKeys, mismatchValues);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof a === "object" && typeof b === "object") {
|
||||||
|
return this.compareObjects_(a, b, mismatchKeys, mismatchValues);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Straight check
|
||||||
|
return (a === b);
|
||||||
|
};
|
||||||
|
|
||||||
|
jasmine.Env.prototype.contains_ = function(haystack, needle) {
|
||||||
|
if (jasmine.isArray_(haystack)) {
|
||||||
|
for (var i = 0; i < haystack.length; i++) {
|
||||||
|
if (this.equals_(haystack[i], needle)) return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return haystack.indexOf(needle) >= 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
jasmine.Env.prototype.addEqualityTester = function(equalityTester) {
|
||||||
|
this.equalityTesters_.push(equalityTester);
|
||||||
|
};
|
||||||
|
}());
|
||||||
/** No-op base class for Jasmine reporters.
|
/** No-op base class for Jasmine reporters.
|
||||||
*
|
*
|
||||||
* @constructor
|
* @constructor
|
||||||
@@ -994,7 +999,6 @@ jasmine.Matchers = function(env, actual, spec, opt_isNot) {
|
|||||||
this.actual = actual;
|
this.actual = actual;
|
||||||
this.spec = spec;
|
this.spec = spec;
|
||||||
this.isNot = opt_isNot || false;
|
this.isNot = opt_isNot || false;
|
||||||
this.reportWasCalled_ = false;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// todo: @deprecated as of Jasmine 0.11, remove soon [xw]
|
// todo: @deprecated as of Jasmine 0.11, remove soon [xw]
|
||||||
@@ -1002,14 +1006,8 @@ jasmine.Matchers.pp = function(str) {
|
|||||||
throw new Error("jasmine.Matchers.pp() is no longer supported, please use jasmine.pp() instead!");
|
throw new Error("jasmine.Matchers.pp() is no longer supported, please use jasmine.pp() instead!");
|
||||||
};
|
};
|
||||||
|
|
||||||
// todo: @deprecated Deprecated as of Jasmine 0.10. Rewrite your custom matchers to return true or false. [xw]
|
|
||||||
jasmine.Matchers.prototype.report = function(result, failing_message, details) {
|
|
||||||
throw new Error("As of jasmine 0.11, custom matchers must be implemented differently -- please see jasmine docs");
|
|
||||||
};
|
|
||||||
|
|
||||||
jasmine.Matchers.wrapInto_ = function(prototype, matchersClass) {
|
jasmine.Matchers.wrapInto_ = function(prototype, matchersClass) {
|
||||||
for (var methodName in prototype) {
|
for (var methodName in prototype) {
|
||||||
if (methodName == 'report') continue;
|
|
||||||
var orig = prototype[methodName];
|
var orig = prototype[methodName];
|
||||||
matchersClass.prototype[methodName] = jasmine.Matchers.matcherFn_(methodName, orig);
|
matchersClass.prototype[methodName] = jasmine.Matchers.matcherFn_(methodName, orig);
|
||||||
}
|
}
|
||||||
@@ -1024,8 +1022,6 @@ jasmine.Matchers.matcherFn_ = function(matcherName, matcherFunction) {
|
|||||||
result = !result;
|
result = !result;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.reportWasCalled_) return result;
|
|
||||||
|
|
||||||
var message;
|
var message;
|
||||||
if (!result) {
|
if (!result) {
|
||||||
if (this.message) {
|
if (this.message) {
|
||||||
@@ -1875,7 +1871,7 @@ jasmine.Queue.prototype.next_ = function() {
|
|||||||
|
|
||||||
while (goAgain) {
|
while (goAgain) {
|
||||||
goAgain = false;
|
goAgain = false;
|
||||||
|
|
||||||
if (self.index < self.blocks.length && !(this.abort && !this.ensured[self.index])) {
|
if (self.index < self.blocks.length && !(this.abort && !this.ensured[self.index])) {
|
||||||
var calledSynchronously = true;
|
var calledSynchronously = true;
|
||||||
var completedSynchronously = false;
|
var completedSynchronously = false;
|
||||||
@@ -1913,7 +1909,7 @@ jasmine.Queue.prototype.next_ = function() {
|
|||||||
if (completedSynchronously) {
|
if (completedSynchronously) {
|
||||||
onComplete();
|
onComplete();
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
self.running = false;
|
self.running = false;
|
||||||
if (self.onComplete) {
|
if (self.onComplete) {
|
||||||
@@ -1922,18 +1918,6 @@ jasmine.Queue.prototype.next_ = function() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
jasmine.Queue.prototype.results = function() {
|
|
||||||
var results = new jasmine.NestedResults();
|
|
||||||
for (var i = 0; i < this.blocks.length; i++) {
|
|
||||||
if (this.blocks[i].results) {
|
|
||||||
results.addResult(this.blocks[i].results());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return results;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Runner
|
* Runner
|
||||||
*
|
*
|
||||||
@@ -2007,10 +1991,6 @@ jasmine.Runner.prototype.topLevelSuites = function() {
|
|||||||
}
|
}
|
||||||
return topLevelSuites;
|
return topLevelSuites;
|
||||||
};
|
};
|
||||||
|
|
||||||
jasmine.Runner.prototype.results = function() {
|
|
||||||
return this.queue.results();
|
|
||||||
};
|
|
||||||
/**
|
/**
|
||||||
* Internal representation of a Jasmine specification, or test.
|
* Internal representation of a Jasmine specification, or test.
|
||||||
*
|
*
|
||||||
@@ -2303,10 +2283,6 @@ jasmine.Suite.prototype.afterEach = function(afterEachFunction) {
|
|||||||
this.after_.unshift(afterEachFunction);
|
this.after_.unshift(afterEachFunction);
|
||||||
};
|
};
|
||||||
|
|
||||||
jasmine.Suite.prototype.results = function() {
|
|
||||||
return this.queue.results();
|
|
||||||
};
|
|
||||||
|
|
||||||
jasmine.Suite.prototype.add = function(suiteOrSpec) {
|
jasmine.Suite.prototype.add = function(suiteOrSpec) {
|
||||||
this.children_.push(suiteOrSpec);
|
this.children_.push(suiteOrSpec);
|
||||||
if (suiteOrSpec instanceof jasmine.Suite) {
|
if (suiteOrSpec instanceof jasmine.Suite) {
|
||||||
|
|||||||
+12
-93
@@ -59,117 +59,36 @@ describe('Exceptions:', function() {
|
|||||||
|
|
||||||
describe("with catch on exception", function() {
|
describe("with catch on exception", function() {
|
||||||
it('should handle exceptions thrown, but continue', function() {
|
it('should handle exceptions thrown, but continue', function() {
|
||||||
var fakeTimer = new jasmine.FakeTimer();
|
var ranSecondTest = false,
|
||||||
env.setTimeout = fakeTimer.setTimeout;
|
suite = env.describe('Suite for handles exceptions', function () {
|
||||||
env.clearTimeout = fakeTimer.clearTimeout;
|
|
||||||
env.setInterval = fakeTimer.setInterval;
|
|
||||||
env.clearInterval = fakeTimer.clearInterval;
|
|
||||||
|
|
||||||
//we run two exception tests to make sure we continue after throwing an exception
|
|
||||||
var suite = env.describe('Suite for handles exceptions', function () {
|
|
||||||
env.it('should be a test that fails because it throws an exception', function() {
|
env.it('should be a test that fails because it throws an exception', function() {
|
||||||
throw new Error('fake error 1');
|
throw new Error();
|
||||||
});
|
});
|
||||||
|
|
||||||
env.it('should be another test that fails because it throws an exception', function() {
|
|
||||||
this.runs(function () {
|
|
||||||
throw new Error('fake error 2');
|
|
||||||
});
|
|
||||||
this.runs(function () {
|
|
||||||
this.expect(true).toEqual(true);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
env.it('should be a passing test that runs after exceptions are thrown', function() {
|
|
||||||
this.expect(true).toEqual(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
env.it('should be another test that fails because it throws an exception after a wait', function() {
|
|
||||||
this.runs(function () {
|
|
||||||
var foo = 'foo';
|
|
||||||
});
|
|
||||||
this.waits(250);
|
|
||||||
this.runs(function () {
|
|
||||||
throw new Error('fake error 3');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
env.it('should be a passing test that runs after exceptions are thrown from a async test', function() {
|
env.it('should be a passing test that runs after exceptions are thrown from a async test', function() {
|
||||||
this.expect(true).toEqual(true);
|
ranSecondTest = true;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
var runner = env.currentRunner();
|
|
||||||
suite.execute();
|
suite.execute();
|
||||||
fakeTimer.tick(2500);
|
expect(ranSecondTest).toBe(true);
|
||||||
|
|
||||||
var suiteResults = suite.results();
|
|
||||||
var specResults = suiteResults.getItems();
|
|
||||||
|
|
||||||
expect(suiteResults.passed()).toEqual(false);
|
|
||||||
//
|
|
||||||
expect(specResults.length).toEqual(5);
|
|
||||||
expect(specResults[0].passed()).toMatch(false);
|
|
||||||
var blockResults = specResults[0].getItems();
|
|
||||||
expect(blockResults[0].passed).toEqual(false);
|
|
||||||
expect(blockResults[0].message).toMatch(/fake error 1/);
|
|
||||||
|
|
||||||
expect(specResults[1].passed()).toEqual(false);
|
|
||||||
blockResults = specResults[1].getItems();
|
|
||||||
expect(blockResults[0].passed).toEqual(false);
|
|
||||||
expect(blockResults[0].message).toMatch(/fake error 2/);
|
|
||||||
expect(blockResults[1].passed).toEqual(true);
|
|
||||||
|
|
||||||
expect(specResults[2].passed()).toEqual(true);
|
|
||||||
|
|
||||||
expect(specResults[3].passed()).toEqual(false);
|
|
||||||
blockResults = specResults[3].getItems();
|
|
||||||
expect(blockResults[0].message).toMatch(/fake error 3/);
|
|
||||||
|
|
||||||
expect(specResults[4].passed()).toEqual(true);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should handle exceptions thrown directly in top-level describe blocks and continue", function () {
|
it("should handle exceptions thrown directly in top-level describe blocks and continue", function () {
|
||||||
var suite = env.describe("a top level describe block that throws an exception", function () {
|
var ranSecondDescribe = false, suite, suite2, runner = env.currentRunner();
|
||||||
|
suite = env.describe("a suite that throws an exception", function () {
|
||||||
env.it("is a test that should pass", function () {
|
env.it("is a test that should pass", function () {
|
||||||
this.expect(true).toEqual(true);
|
this.expect(true).toEqual(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
throw new Error("top level error");
|
throw new Error("top level error");
|
||||||
});
|
});
|
||||||
|
suite2 = env.describe("a suite that doesn't throw an exception", function () {
|
||||||
suite.execute();
|
ranSecondDescribe = true;
|
||||||
var suiteResults = suite.results();
|
|
||||||
var specResults = suiteResults.getItems();
|
|
||||||
|
|
||||||
expect(suiteResults.passed()).toEqual(false);
|
|
||||||
expect(specResults.length).toEqual(2);
|
|
||||||
|
|
||||||
expect(specResults[1].description).toMatch(/encountered a declaration exception/);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("should handle exceptions thrown directly in nested describe blocks and continue", function () {
|
|
||||||
var suite = env.describe("a top level describe", function () {
|
|
||||||
env.describe("a mid-level describe that throws an exception", function () {
|
|
||||||
env.it("is a test that should pass", function () {
|
|
||||||
this.expect(true).toEqual(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
throw new Error("a mid-level error");
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
suite.execute();
|
runner.execute();
|
||||||
var suiteResults = suite.results();
|
expect(ranSecondDescribe).toBe(true);
|
||||||
var specResults = suiteResults.getItems();
|
|
||||||
|
|
||||||
expect(suiteResults.passed()).toEqual(false);
|
|
||||||
expect(specResults.length).toEqual(1);
|
|
||||||
|
|
||||||
var nestedSpecResults = specResults[0].getItems();
|
|
||||||
|
|
||||||
expect(nestedSpecResults.length).toEqual(2);
|
|
||||||
expect(nestedSpecResults[1].description).toMatch(/encountered a declaration exception/);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
+31
-126
@@ -14,105 +14,83 @@ describe('RunnerTest', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('beforeEach', function() {
|
describe('beforeEach', function() {
|
||||||
it('should run before each spec for all suites', function () {
|
it('should run before each spec for all suites', function() {
|
||||||
var foo;
|
var foo;
|
||||||
env.beforeEach(function () {
|
env.beforeEach(function() {
|
||||||
foo = 0;
|
foo = 0;
|
||||||
});
|
});
|
||||||
|
|
||||||
env.describe('suite 1', function () {
|
env.describe('suite 1', function() {
|
||||||
env.it('test 1-1', function() {
|
env.it('test 1-1', function() {
|
||||||
foo++;
|
foo++;
|
||||||
this.expect(foo).toEqual(1);
|
expect(foo).toEqual(1);
|
||||||
});
|
});
|
||||||
env.it('test 1-2', function() {
|
env.it('test 1-2', function() {
|
||||||
foo++;
|
foo++;
|
||||||
this.expect(foo).toEqual(1);
|
expect(foo).toEqual(1);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
env.describe('suite 2', function () {
|
env.describe('suite 2', function() {
|
||||||
env.it('test 2-1', function() {
|
env.it('test 2-1', function() {
|
||||||
foo++;
|
foo++;
|
||||||
this.expect(foo).toEqual(1);
|
expect(foo).toEqual(1);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
env.currentRunner().execute();
|
env.currentRunner().execute();
|
||||||
|
|
||||||
var runnerResults = env.currentRunner().results();
|
|
||||||
expect(runnerResults.totalCount).toEqual(3);
|
|
||||||
expect(runnerResults.passedCount).toEqual(3);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should provide all specs', function() {
|
||||||
|
|
||||||
it('should provide all specs', function () {
|
env.describe('suite 1', function() {
|
||||||
var foo;
|
|
||||||
env.beforeEach(function () {
|
|
||||||
foo = 0;
|
|
||||||
});
|
|
||||||
|
|
||||||
env.describe('suite 1', function () {
|
|
||||||
env.it('test 1-1', function() {
|
env.it('test 1-1', function() {
|
||||||
foo++;
|
|
||||||
this.expect(foo).toEqual(1);
|
|
||||||
});
|
});
|
||||||
env.it('test 1-2', function() {
|
env.it('test 1-2', function() {
|
||||||
foo++;
|
|
||||||
this.expect(foo).toEqual(1);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
env.describe('suite 2', function () {
|
env.describe('suite 2', function() {
|
||||||
env.it('test 2-1', function() {
|
env.it('test 2-1', function() {
|
||||||
foo++;
|
|
||||||
this.expect(foo).toEqual(1);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
env.currentRunner().execute();
|
|
||||||
|
|
||||||
|
|
||||||
expect(env.currentRunner().specs().length).toEqual(3);
|
expect(env.currentRunner().specs().length).toEqual(3);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('afterEach', function() {
|
describe('afterEach', function() {
|
||||||
it('should run after each spec for all suites', function () {
|
it('should run after each spec for all suites', function() {
|
||||||
var foo = 3;
|
var foo = 3;
|
||||||
env.afterEach(function () {
|
env.afterEach(function() {
|
||||||
foo = foo - 1;
|
foo = foo - 1;
|
||||||
});
|
});
|
||||||
|
|
||||||
env.describe('suite 1', function () {
|
env.describe('suite 1', function() {
|
||||||
env.it('test 1-1', function() {
|
env.it('test 1-1', function() {
|
||||||
this.expect(foo).toEqual(3);
|
expect(foo).toEqual(3);
|
||||||
});
|
});
|
||||||
env.it('test 1-2', function() {
|
env.it('test 1-2', function() {
|
||||||
this.expect(foo).toEqual(2);
|
expect(foo).toEqual(2);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
env.describe('suite 2', function () {
|
env.describe('suite 2', function() {
|
||||||
env.it('test 2-1', function() {
|
env.it('test 2-1', function() {
|
||||||
this.expect(foo).toEqual(1);
|
expect(foo).toEqual(1);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
env.currentRunner().execute();
|
env.currentRunner().execute();
|
||||||
|
|
||||||
var runnerResults = env.currentRunner().results();
|
|
||||||
expect(runnerResults.totalCount).toEqual(3);
|
|
||||||
expect(runnerResults.passedCount).toEqual(3);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should run after a failing spec', function () {
|
it('should run after a failing spec', function () {
|
||||||
var afterEach = originalJasmine.createSpy();
|
var afterEach = originalJasmine.createSpy();
|
||||||
env.afterEach(afterEach);
|
env.afterEach(afterEach);
|
||||||
|
|
||||||
env.describe('suite', function () {
|
env.describe('suite',function() {
|
||||||
env.it('fails', function () {
|
env.it('fails', function() {
|
||||||
this.explodes();
|
this.fail();
|
||||||
});
|
});
|
||||||
}).execute();
|
}).execute();
|
||||||
|
|
||||||
@@ -120,103 +98,32 @@ describe('RunnerTest', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should run child suites and specs and generate results when execute is called', function() {
|
|
||||||
env.describe('one suite description', function () {
|
|
||||||
env.it('should be a test', function() {
|
|
||||||
this.runs(function () {
|
|
||||||
this.expect(true).toEqual(true);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
env.describe('another suite description', function () {
|
|
||||||
env.it('should be another test', function() {
|
|
||||||
this.runs(function () {
|
|
||||||
this.expect(true).toEqual(false);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
env.currentRunner().execute();
|
|
||||||
|
|
||||||
var runnerResults = env.currentRunner().results();
|
|
||||||
expect(runnerResults.totalCount).toEqual(2);
|
|
||||||
expect(runnerResults.passedCount).toEqual(1);
|
|
||||||
expect(runnerResults.failedCount).toEqual(1);
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
it('should ignore suites that have been x\'d', function() {
|
it('should ignore suites that have been x\'d', function() {
|
||||||
env.xdescribe('one suite description', function () {
|
var disabledDescribe = jasmine.createSpy('xdescribe');
|
||||||
env.it('should be a test', function() {
|
env.xdescribe('one suite description', disabledDescribe);
|
||||||
this.runs(function () {
|
|
||||||
this.expect(true).toEqual(true);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
env.describe('another suite description', function () {
|
|
||||||
env.it('should be another test', function() {
|
|
||||||
this.runs(function () {
|
|
||||||
this.expect(true).toEqual(false);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
env.currentRunner().execute();
|
env.currentRunner().execute();
|
||||||
|
expect(disabledDescribe).not.toHaveBeenCalled();
|
||||||
var runnerResults = env.currentRunner().results();
|
|
||||||
expect(runnerResults.totalCount).toEqual(1);
|
|
||||||
expect(runnerResults.passedCount).toEqual(0);
|
|
||||||
expect(runnerResults.failedCount).toEqual(1);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should roll up results from all specs', function() {
|
describe('reporting', function() {
|
||||||
env.describe('one suite description', function () {
|
|
||||||
env.it('should be a test', function() {
|
|
||||||
this.runs(function () {
|
|
||||||
this.expect(true).toEqual(true);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
env.describe('another suite description', function () {
|
|
||||||
env.it('should be another test', function() {
|
|
||||||
this.runs(function () {
|
|
||||||
this.expect(true).toEqual(false);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
env.currentRunner().execute();
|
|
||||||
|
|
||||||
var results = env.currentRunner().results();
|
|
||||||
expect(results.totalCount).toEqual(2);
|
|
||||||
expect(results.passedCount).toEqual(1);
|
|
||||||
expect(results.failedCount).toEqual(1);
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('reporting', function () {
|
|
||||||
var fakeReporter;
|
var fakeReporter;
|
||||||
beforeEach(function () {
|
|
||||||
fakeReporter = originalJasmine.createSpyObj("fakeReporter", ["log", "reportRunnerStarting", "reportRunnerResults"]);
|
fakeReporter = originalJasmine.createSpyObj("fakeReporter", ["log", "reportRunnerStarting", "reportRunnerResults"]);
|
||||||
env.addReporter(fakeReporter);
|
env.addReporter(fakeReporter);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should report runner results when the runner has completed running', function() {
|
it('should report runner results when the runner has completed running', function() {
|
||||||
env.describe('one suite description', function () {
|
env.describe('one suite description', function() {
|
||||||
env.it('should be a test', function() {
|
env.it('should be a test', function() {
|
||||||
this.runs(function () {
|
this.runs(function() {
|
||||||
this.expect(true).toEqual(true);
|
this.expect(true).toEqual(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
env.describe('another suite description', function () {
|
env.describe('another suite description', function() {
|
||||||
env.it('should be another test', function() {
|
env.it('should be another test', function() {
|
||||||
this.waits(200);
|
this.waits(200);
|
||||||
this.runs(function () {
|
this.runs(function() {
|
||||||
this.expect(true).toEqual(false);
|
this.expect(true).toEqual(false);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -225,10 +132,7 @@ describe('RunnerTest', function() {
|
|||||||
env.currentRunner().execute();
|
env.currentRunner().execute();
|
||||||
expect(fakeReporter.reportRunnerResults).not.toHaveBeenCalled();
|
expect(fakeReporter.reportRunnerResults).not.toHaveBeenCalled();
|
||||||
fakeTimer.tick(200);
|
fakeTimer.tick(200);
|
||||||
//This blows up the JSApiReporter.
|
expect(fakeReporter.reportRunnerResults).toHaveBeenCalledWith(env.currentRunner());
|
||||||
//expect(fakeReporter.reportRunnerResults).toHaveBeenCalledWith(env.currentRunner);
|
|
||||||
expect(fakeReporter.reportRunnerResults).toHaveBeenCalled();
|
|
||||||
expect(fakeReporter.reportRunnerResults.mostRecentCall.args[0].results()).toEqual(env.currentRunner().results());
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -264,7 +168,8 @@ describe('RunnerTest', function() {
|
|||||||
suite2 = env.describe("suite 2", function() {
|
suite2 = env.describe("suite 2", function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
suite3 = env.describe("suite 3", function() {});
|
suite3 = env.describe("suite 3", function() {
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("#suites should return a flat array of all suites, including nested suites", function() {
|
it("#suites should return a flat array of all suites, including nested suites", function() {
|
||||||
|
|||||||
+18
-222
@@ -576,66 +576,6 @@ describe("jasmine spec running", function () {
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("testBeforeAndAfterCallbacks", function () {
|
|
||||||
var suiteWithBefore = env.describe('one suite with a before', function () {
|
|
||||||
|
|
||||||
this.beforeEach(function () {
|
|
||||||
this.foo = 1;
|
|
||||||
});
|
|
||||||
|
|
||||||
env.it('should be a spec', function () {
|
|
||||||
this.runs(function() {
|
|
||||||
this.foo++;
|
|
||||||
this.expect(this.foo).toEqual(2);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
env.it('should be another spec', function () {
|
|
||||||
this.runs(function() {
|
|
||||||
this.foo++;
|
|
||||||
this.expect(this.foo).toEqual(2);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
suiteWithBefore.execute();
|
|
||||||
|
|
||||||
var suite = suiteWithBefore;
|
|
||||||
|
|
||||||
expect(suite.results().getItems()[0].passed()).toEqual(true); // "testBeforeAndAfterCallbacks: the first spec's foo should have been 2");
|
|
||||||
expect(suite.results().getItems()[1].passed()).toEqual(true); // "testBeforeAndAfterCallbacks: the second spec's this.foo should have been 2");
|
|
||||||
|
|
||||||
|
|
||||||
var foo = 1;
|
|
||||||
var suiteWithAfter = env.describe('one suite with an after_each', function () {
|
|
||||||
|
|
||||||
env.it('should be a spec with an after_each', function () {
|
|
||||||
this.expect(foo).toEqual(1);
|
|
||||||
foo++;
|
|
||||||
this.expect(foo).toEqual(2);
|
|
||||||
});
|
|
||||||
|
|
||||||
env.it('should be another spec with an after_each', function () {
|
|
||||||
this.expect(foo).toEqual(0);
|
|
||||||
foo++;
|
|
||||||
this.expect(foo).toEqual(1);
|
|
||||||
});
|
|
||||||
|
|
||||||
this.afterEach(function () {
|
|
||||||
foo = 0;
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
suiteWithAfter.execute();
|
|
||||||
|
|
||||||
suite = suiteWithAfter;
|
|
||||||
expect(suite.afterEach.length).toEqual(1);
|
|
||||||
expect(suite.results().getItems()[0].passed()).toEqual(true);
|
|
||||||
expect(suite.results().getItems()[1].passed()).toEqual(true);
|
|
||||||
expect(foo).toEqual(0);
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
it('#waits should allow consecutive waits calls', function () {
|
it('#waits should allow consecutive waits calls', function () {
|
||||||
var foo = 0;
|
var foo = 0;
|
||||||
var waitsSuite = env.describe('suite that waits', function () {
|
var waitsSuite = env.describe('suite that waits', function () {
|
||||||
@@ -873,85 +813,6 @@ describe("jasmine spec running", function () {
|
|||||||
expect(secondSpecHasRun).toEqual(true);
|
expect(secondSpecHasRun).toEqual(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("testBeforeExecutesSafely", function() {
|
|
||||||
var report = "";
|
|
||||||
var suite = env.describe('before fails on first test, passes on second', function() {
|
|
||||||
var counter = 0;
|
|
||||||
this.beforeEach(function() {
|
|
||||||
counter++;
|
|
||||||
if (counter == 1) {
|
|
||||||
throw "before failure";
|
|
||||||
}
|
|
||||||
});
|
|
||||||
env.it("first should not run because before fails", function() {
|
|
||||||
this.runs(function() {
|
|
||||||
report += "first";
|
|
||||||
this.expect(true).toEqual(true);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
env.it("second should run and pass because before passes", function() {
|
|
||||||
this.runs(function() {
|
|
||||||
report += "second";
|
|
||||||
this.expect(true).toEqual(true);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
suite.execute();
|
|
||||||
|
|
||||||
expect(report).toEqual("firstsecond");
|
|
||||||
var suiteResults = suite.results();
|
|
||||||
expect(suiteResults.getItems()[0].getItems()[0].passed).toEqual(false);
|
|
||||||
expect(suiteResults.getItems()[1].getItems()[0].passed).toEqual(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("testAfterExecutesSafely", function() {
|
|
||||||
var report = "";
|
|
||||||
var suite = env.describe('after fails on first test, then passes', function() {
|
|
||||||
var counter = 0;
|
|
||||||
this.afterEach(function() {
|
|
||||||
counter++;
|
|
||||||
if (counter == 1) {
|
|
||||||
throw "after failure";
|
|
||||||
}
|
|
||||||
});
|
|
||||||
env.it("first should run, expectation passes, but spec fails because after fails", function() {
|
|
||||||
this.runs(function() {
|
|
||||||
report += "first";
|
|
||||||
this.expect(true).toEqual(true);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
env.it("second should run and pass because after passes", function() {
|
|
||||||
this.runs(function() {
|
|
||||||
report += "second";
|
|
||||||
this.expect(true).toEqual(true);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
env.it("third should run and pass because after passes", function() {
|
|
||||||
this.runs(function() {
|
|
||||||
report += "third";
|
|
||||||
this.expect(true).toEqual(true);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
suite.execute();
|
|
||||||
|
|
||||||
expect(report).toEqual("firstsecondthird"); // "all tests should run");
|
|
||||||
//After each errors should not go in spec results because it confuses the count.
|
|
||||||
var suiteResults = suite.results();
|
|
||||||
expect(suiteResults.getItems().length).toEqual(3, 'testAfterExecutesSafely should have results for three specs');
|
|
||||||
|
|
||||||
expect(suiteResults.getItems()[0].getItems()[0].passed).toEqual(true, "testAfterExecutesSafely 1st spec should pass");
|
|
||||||
expect(suiteResults.getItems()[1].getItems()[0].passed).toEqual(true, "testAfterExecutesSafely 2nd spec should pass");
|
|
||||||
expect(suiteResults.getItems()[2].getItems()[0].passed).toEqual(true, "testAfterExecutesSafely 3rd spec should pass");
|
|
||||||
|
|
||||||
expect(suiteResults.getItems()[0].getItems()[0].passed).toEqual(true, "testAfterExecutesSafely 1st result for 1st suite spec should pass");
|
|
||||||
expect(suiteResults.getItems()[0].getItems()[1].passed).toEqual(false, "testAfterExecutesSafely 2nd result for 1st suite spec should fail because afterEach failed");
|
|
||||||
expect(suiteResults.getItems()[1].getItems()[0].passed).toEqual(true, "testAfterExecutesSafely 2nd suite spec should pass");
|
|
||||||
expect(suiteResults.getItems()[2].getItems()[0].passed).toEqual(true, "testAfterExecutesSafely 3rd suite spec should pass");
|
|
||||||
});
|
|
||||||
|
|
||||||
it("should permit nested describes", function() {
|
it("should permit nested describes", function() {
|
||||||
var actions = [];
|
var actions = [];
|
||||||
|
|
||||||
@@ -1115,101 +976,36 @@ describe("jasmine spec running", function () {
|
|||||||
expect(nestedSpec.getFullName()).toEqual('Test Subject when under circumstance A and circumstance B behaves thusly.'); //, "Spec.fullName was incorrect: " + nestedSpec.getFullName());
|
expect(nestedSpec.getFullName()).toEqual('Test Subject when under circumstance A and circumstance B behaves thusly.'); //, "Spec.fullName was incorrect: " + nestedSpec.getFullName());
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should skip empty suites", function () {
|
|
||||||
env.describe('NonEmptySuite1', function() {
|
|
||||||
env.it('should pass', function() {
|
|
||||||
this.expect(true).toEqual(true);
|
|
||||||
});
|
|
||||||
env.describe('NestedEmptySuite', function() {
|
|
||||||
});
|
|
||||||
env.it('should pass', function() {
|
|
||||||
this.expect(true).toEqual(true);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
env.describe('EmptySuite', function() {
|
|
||||||
});
|
|
||||||
|
|
||||||
env.describe('NonEmptySuite2', function() {
|
|
||||||
env.it('should pass', function() {
|
|
||||||
this.expect(true).toEqual(true);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
env.execute();
|
|
||||||
|
|
||||||
var runnerResults = env.currentRunner_.results();
|
|
||||||
expect(runnerResults.totalCount).toEqual(3);
|
|
||||||
expect(runnerResults.passedCount).toEqual(3);
|
|
||||||
expect(runnerResults.failedCount).toEqual(0);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("should bind 'this' to the running spec within the spec body", function() {
|
it("should bind 'this' to the running spec within the spec body", function() {
|
||||||
var spec;
|
var specExecuted = jasmine.createSpy(), spec;
|
||||||
var suite = env.describe('one suite description', function () {
|
|
||||||
env.it('should be a test with queuedFunctions', function() {
|
env.describe('Test Subject', function() {
|
||||||
spec = this.runs(function() {
|
spec = env.it('should be a test with queuedFunctions', function() {
|
||||||
|
this.runs(function() {
|
||||||
this.foo = 0;
|
this.foo = 0;
|
||||||
|
expect(this.foo).toBe(0);
|
||||||
|
specExecuted();
|
||||||
|
});
|
||||||
|
|
||||||
|
this.runs(function() {
|
||||||
this.foo++;
|
this.foo++;
|
||||||
});
|
expect(this.foo).toBe(1);
|
||||||
|
specExecuted();
|
||||||
this.runs(function() {
|
|
||||||
var that = this;
|
|
||||||
fakeTimer.setTimeout(function() {
|
|
||||||
that.foo++;
|
|
||||||
}, 250);
|
|
||||||
});
|
|
||||||
|
|
||||||
this.runs(function() {
|
|
||||||
this.expect(this.foo).toEqual(2);
|
|
||||||
});
|
|
||||||
|
|
||||||
this.waits(300);
|
|
||||||
|
|
||||||
this.runs(function() {
|
|
||||||
this.expect(this.foo).toEqual(2);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
suite.execute();
|
spec.execute();
|
||||||
fakeTimer.tick(600);
|
expect(specExecuted.callCount).toBe(2);
|
||||||
expect(spec.foo).toEqual(2);
|
|
||||||
var suiteResults = suite.results();
|
|
||||||
expect(suiteResults.getItems()[0].getItems().length).toEqual(2);
|
|
||||||
expect(suiteResults.getItems()[0].getItems()[0].passed).toEqual(false);
|
|
||||||
expect(suiteResults.getItems()[0].getItems()[1].passed).toEqual(true);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("shouldn't run disabled tests", function() {
|
it("shouldn't run disabled tests", function() {
|
||||||
var xitSpecWasRun = false;
|
var disabledSpec = originalJasmine.createSpy('disabledSpec'),
|
||||||
var suite = env.describe('default current suite', function() {
|
suite = env.describe('default current suite', function() {
|
||||||
env.xit('disabled spec').runs(function () {
|
env.xit('disabled spec').runs(disabledSpec);
|
||||||
xitSpecWasRun = true;
|
|
||||||
});
|
|
||||||
|
|
||||||
env.it('enabled spec').runs(function () {
|
|
||||||
var foo = 'bar';
|
|
||||||
expect(foo).toEqual('bar');
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
suite.execute();
|
suite.execute();
|
||||||
expect(xitSpecWasRun).toEqual(false);
|
expect(disabledSpec).not.toHaveBeenCalled();
|
||||||
});
|
|
||||||
|
|
||||||
it('shouldn\'t execute specs in disabled suites', function() {
|
|
||||||
var spy = originalJasmine.createSpy();
|
|
||||||
var disabledSuite = env.xdescribe('a disabled suite', function() {
|
|
||||||
env.it('enabled spec, but should not be run', function() {
|
|
||||||
spy();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
disabledSuite.execute();
|
|
||||||
|
|
||||||
expect(spy).not.toHaveBeenCalled();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('#explodes should throw an exception when it is called inside a spec', function() {
|
it('#explodes should throw an exception when it is called inside a spec', function() {
|
||||||
|
|||||||
@@ -1,239 +0,0 @@
|
|||||||
describe("TrivialReporter", function() {
|
|
||||||
var env;
|
|
||||||
var trivialReporter;
|
|
||||||
var body;
|
|
||||||
var fakeDocument;
|
|
||||||
|
|
||||||
beforeEach(function() {
|
|
||||||
env = new jasmine.Env();
|
|
||||||
env.updateInterval = 0;
|
|
||||||
|
|
||||||
body = document.createElement("body");
|
|
||||||
fakeDocument = { body: body, location: { search: "" } };
|
|
||||||
trivialReporter = new jasmine.TrivialReporter(fakeDocument);
|
|
||||||
});
|
|
||||||
|
|
||||||
function fakeSpec(name) {
|
|
||||||
return {
|
|
||||||
getFullName: function() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function findElements(divs, withClass) {
|
|
||||||
var els = [];
|
|
||||||
for (var i = 0; i < divs.length; i++) {
|
|
||||||
if (divs[i].className == withClass) els.push(divs[i]);
|
|
||||||
}
|
|
||||||
return els;
|
|
||||||
}
|
|
||||||
|
|
||||||
function findElement(divs, withClass) {
|
|
||||||
var els = findElements(divs, withClass);
|
|
||||||
if (els.length > 0) {
|
|
||||||
return els[0];
|
|
||||||
}
|
|
||||||
throw new Error("couldn't find div with class " + withClass);
|
|
||||||
}
|
|
||||||
|
|
||||||
it("should run only specs beginning with spec parameter", function() {
|
|
||||||
fakeDocument.location.search = "?spec=run%20this";
|
|
||||||
expect(trivialReporter.specFilter(fakeSpec("run this"))).toBeTruthy();
|
|
||||||
expect(trivialReporter.specFilter(fakeSpec("not the right spec"))).toBeFalsy();
|
|
||||||
expect(trivialReporter.specFilter(fakeSpec("not run this"))).toBeFalsy();
|
|
||||||
});
|
|
||||||
|
|
||||||
it("should display empty divs for every suite when the runner is starting", function() {
|
|
||||||
trivialReporter.reportRunnerStarting({
|
|
||||||
env: env,
|
|
||||||
suites: function() {
|
|
||||||
return [ new jasmine.Suite({}, "suite 1", null, null) ];
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
var divs = findElements(body.getElementsByTagName("div"), "suite");
|
|
||||||
expect(divs.length).toEqual(1);
|
|
||||||
expect(divs[0].innerHTML).toContain("suite 1");
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('Matcher reporting', function () {
|
|
||||||
var getResultMessageDiv = function (body) {
|
|
||||||
var divs = body.getElementsByTagName("div");
|
|
||||||
for (var i = 0; i < divs.length; i++) {
|
|
||||||
if (divs[i].className.match(/resultMessage/)) {
|
|
||||||
return divs[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
var runner, spec, fakeTimer;
|
|
||||||
beforeEach(function () {
|
|
||||||
fakeTimer = new originalJasmine.FakeTimer();
|
|
||||||
env.setTimeout = fakeTimer.setTimeout;
|
|
||||||
env.clearTimeout = fakeTimer.clearTimeout;
|
|
||||||
env.setInterval = fakeTimer.setInterval;
|
|
||||||
env.clearInterval = fakeTimer.clearInterval;
|
|
||||||
runner = env.currentRunner();
|
|
||||||
var suite = new jasmine.Suite(env, 'some suite');
|
|
||||||
runner.add(suite);
|
|
||||||
spec = new jasmine.Spec(env, suite, 'some spec');
|
|
||||||
suite.add(spec);
|
|
||||||
fakeDocument.location.search = "?";
|
|
||||||
env.addReporter(trivialReporter);
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('toContain', function () {
|
|
||||||
it('should show actual and expected', function () {
|
|
||||||
spec.runs(function () {
|
|
||||||
this.expect('foo').toContain('bar');
|
|
||||||
});
|
|
||||||
runner.execute();
|
|
||||||
fakeTimer.tick(0);
|
|
||||||
|
|
||||||
var resultEl = getResultMessageDiv(body);
|
|
||||||
expect(resultEl.innerHTML).toMatch(/foo/);
|
|
||||||
expect(resultEl.innerHTML).toMatch(/bar/);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("failure messages (integration)", function () {
|
|
||||||
var spec, results, expectationResult;
|
|
||||||
|
|
||||||
beforeEach(function() {
|
|
||||||
results = {
|
|
||||||
passed: function() {
|
|
||||||
return false;
|
|
||||||
},
|
|
||||||
getItems: function() {
|
|
||||||
}};
|
|
||||||
|
|
||||||
var suite1 = new jasmine.Suite(env, "suite 1", null, null);
|
|
||||||
|
|
||||||
spec = {
|
|
||||||
suite: suite1,
|
|
||||||
getFullName: function() {
|
|
||||||
return "foo";
|
|
||||||
},
|
|
||||||
results: function() {
|
|
||||||
return results;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
trivialReporter.reportRunnerStarting({
|
|
||||||
env: env,
|
|
||||||
suites: function() {
|
|
||||||
return [ suite1 ];
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it("should add the failure message to the DOM (non-toEquals matchers)", function() {
|
|
||||||
expectationResult = jasmine.buildExpectationResult({
|
|
||||||
matcherName: "toBeNull", passed: false, message: "Expected 'a' to be null, but it was not"
|
|
||||||
});
|
|
||||||
|
|
||||||
spyOn(results, 'getItems').andReturn([expectationResult]);
|
|
||||||
|
|
||||||
trivialReporter.reportSpecResults(spec);
|
|
||||||
|
|
||||||
var divs = body.getElementsByTagName("div");
|
|
||||||
var errorDiv = findElement(divs, 'resultMessage fail');
|
|
||||||
expect(errorDiv.innerHTML).toEqual("Expected 'a' to be null, but it was not");
|
|
||||||
});
|
|
||||||
|
|
||||||
it("should add the failure message to the DOM (non-toEquals matchers) html escaping", function() {
|
|
||||||
expectationResult = jasmine.buildExpectationResult({
|
|
||||||
matcherName: "toBeNull", passed: false, message: "Expected '1 < 2' to <b>e null, & it was not"
|
|
||||||
});
|
|
||||||
|
|
||||||
spyOn(results, 'getItems').andReturn([expectationResult]);
|
|
||||||
|
|
||||||
trivialReporter.reportSpecResults(spec);
|
|
||||||
|
|
||||||
var divs = body.getElementsByTagName("div");
|
|
||||||
var errorDiv = findElement(divs, 'resultMessage fail');
|
|
||||||
expect(errorDiv.innerHTML).toEqual("Expected '1 < 2' to <b>e null, & it was not");
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("log messages", function() {
|
|
||||||
it("should appear in the report", function() {
|
|
||||||
env.describe("suite", function() {
|
|
||||||
env.it("will have log messages", function() {
|
|
||||||
this.log("this is a", "multipart log message");
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
env.addReporter(trivialReporter);
|
|
||||||
env.execute();
|
|
||||||
|
|
||||||
var divs = body.getElementsByTagName("div");
|
|
||||||
var errorDiv = findElement(divs, 'resultMessage log');
|
|
||||||
expect(errorDiv.innerHTML).toEqual("this is a multipart log message");
|
|
||||||
});
|
|
||||||
|
|
||||||
xit("should work on IE without console.log.apply", function() {
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("duplicate example names", function() {
|
|
||||||
it("should report failures correctly", function() {
|
|
||||||
var suite1 = env.describe("suite", function() {
|
|
||||||
env.it("will have log messages", function() {
|
|
||||||
this.log("this one fails!");
|
|
||||||
this.expect(true).toBeFalsy();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
var suite2 = env.describe("suite", function() {
|
|
||||||
env.it("will have log messages", function() {
|
|
||||||
this.log("this one passes!");
|
|
||||||
this.expect(true).toBeTruthy();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
env.addReporter(trivialReporter);
|
|
||||||
env.execute();
|
|
||||||
|
|
||||||
var divs = body.getElementsByTagName("div");
|
|
||||||
var passedSpecDiv = findElement(divs, 'suite passed');
|
|
||||||
expect(passedSpecDiv.className).toEqual('suite passed');
|
|
||||||
expect(passedSpecDiv.innerHTML).toContain("this one passes!");
|
|
||||||
expect(passedSpecDiv.innerHTML).not.toContain("this one fails!");
|
|
||||||
|
|
||||||
var failedSpecDiv = findElement(divs, 'suite failed');
|
|
||||||
expect(failedSpecDiv.className).toEqual('suite failed');
|
|
||||||
expect(failedSpecDiv.innerHTML).toContain("this one fails!");
|
|
||||||
expect(failedSpecDiv.innerHTML).not.toContain("this one passes!");
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('#reportSpecStarting', function() {
|
|
||||||
var spec1;
|
|
||||||
beforeEach(function () {
|
|
||||||
env.describe("suite 1", function() {
|
|
||||||
spec1 = env.it("spec 1", function() {
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('DOES NOT log running specs by default', function() {
|
|
||||||
spyOn(trivialReporter, 'log');
|
|
||||||
|
|
||||||
trivialReporter.reportSpecStarting(spec1);
|
|
||||||
|
|
||||||
expect(trivialReporter.log).not.toHaveBeenCalled();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('logs running specs when log_running_specs is true', function() {
|
|
||||||
trivialReporter.logRunningSpecs = true;
|
|
||||||
spyOn(trivialReporter, 'log');
|
|
||||||
|
|
||||||
trivialReporter.reportSpecStarting(spec1);
|
|
||||||
|
|
||||||
expect(trivialReporter.log).toHaveBeenCalledWith('>> Jasmine Running suite 1 spec 1...');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@@ -21,7 +21,6 @@
|
|||||||
<script type="text/javascript" src=".././src/html/ReporterView.js"></script>
|
<script type="text/javascript" src=".././src/html/ReporterView.js"></script>
|
||||||
<script type="text/javascript" src=".././src/html/SpecView.js"></script>
|
<script type="text/javascript" src=".././src/html/SpecView.js"></script>
|
||||||
<script type="text/javascript" src=".././src/html/SuiteView.js"></script>
|
<script type="text/javascript" src=".././src/html/SuiteView.js"></script>
|
||||||
<script type="text/javascript" src=".././src/html/TrivialReporter.js"></script>
|
|
||||||
<script type="text/javascript" src=".././src/console/ConsoleReporter.js"></script>
|
<script type="text/javascript" src=".././src/console/ConsoleReporter.js"></script>
|
||||||
|
|
||||||
<!-- include spec files here... -->
|
<!-- include spec files here... -->
|
||||||
@@ -48,7 +47,6 @@
|
|||||||
<script type="text/javascript" src=".././spec/html/HTMLReporterSpec.js"></script>
|
<script type="text/javascript" src=".././spec/html/HTMLReporterSpec.js"></script>
|
||||||
<script type="text/javascript" src=".././spec/html/MatchersHtmlSpec.js"></script>
|
<script type="text/javascript" src=".././spec/html/MatchersHtmlSpec.js"></script>
|
||||||
<script type="text/javascript" src=".././spec/html/PrettyPrintHtmlSpec.js"></script>
|
<script type="text/javascript" src=".././spec/html/PrettyPrintHtmlSpec.js"></script>
|
||||||
<script type="text/javascript" src=".././spec/html/TrivialReporterSpec.js"></script>
|
|
||||||
<script type="text/javascript" src=".././spec/console/ConsoleReporterSpec.js"></script>
|
<script type="text/javascript" src=".././spec/console/ConsoleReporterSpec.js"></script>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
|||||||
+2
-14
@@ -57,7 +57,7 @@ jasmine.Queue.prototype.next_ = function() {
|
|||||||
|
|
||||||
while (goAgain) {
|
while (goAgain) {
|
||||||
goAgain = false;
|
goAgain = false;
|
||||||
|
|
||||||
if (self.index < self.blocks.length && !(this.abort && !this.ensured[self.index])) {
|
if (self.index < self.blocks.length && !(this.abort && !this.ensured[self.index])) {
|
||||||
var calledSynchronously = true;
|
var calledSynchronously = true;
|
||||||
var completedSynchronously = false;
|
var completedSynchronously = false;
|
||||||
@@ -95,7 +95,7 @@ jasmine.Queue.prototype.next_ = function() {
|
|||||||
if (completedSynchronously) {
|
if (completedSynchronously) {
|
||||||
onComplete();
|
onComplete();
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
self.running = false;
|
self.running = false;
|
||||||
if (self.onComplete) {
|
if (self.onComplete) {
|
||||||
@@ -104,15 +104,3 @@ jasmine.Queue.prototype.next_ = function() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
jasmine.Queue.prototype.results = function() {
|
|
||||||
var results = new jasmine.NestedResults();
|
|
||||||
for (var i = 0; i < this.blocks.length; i++) {
|
|
||||||
if (this.blocks[i].results) {
|
|
||||||
results.addResult(this.blocks[i].results());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return results;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -71,7 +71,3 @@ jasmine.Runner.prototype.topLevelSuites = function() {
|
|||||||
}
|
}
|
||||||
return topLevelSuites;
|
return topLevelSuites;
|
||||||
};
|
};
|
||||||
|
|
||||||
jasmine.Runner.prototype.results = function() {
|
|
||||||
return this.queue.results();
|
|
||||||
};
|
|
||||||
|
|||||||
@@ -47,10 +47,6 @@ jasmine.Suite.prototype.afterEach = function(afterEachFunction) {
|
|||||||
this.after_.unshift(afterEachFunction);
|
this.after_.unshift(afterEachFunction);
|
||||||
};
|
};
|
||||||
|
|
||||||
jasmine.Suite.prototype.results = function() {
|
|
||||||
return this.queue.results();
|
|
||||||
};
|
|
||||||
|
|
||||||
jasmine.Suite.prototype.add = function(suiteOrSpec) {
|
jasmine.Suite.prototype.add = function(suiteOrSpec) {
|
||||||
this.children_.push(suiteOrSpec);
|
this.children_.push(suiteOrSpec);
|
||||||
if (suiteOrSpec instanceof jasmine.Suite) {
|
if (suiteOrSpec instanceof jasmine.Suite) {
|
||||||
|
|||||||
@@ -27,6 +27,9 @@ jasmine.HtmlReporterHelpers.createDom = function(type, attrs, childrenVarArgs) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
jasmine.HtmlReporterHelpers.getSpecStatus = function(child) {
|
jasmine.HtmlReporterHelpers.getSpecStatus = function(child) {
|
||||||
|
if (!child.results) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
var results = child.results();
|
var results = child.results();
|
||||||
var status = results.passed() ? 'passed' : 'failed';
|
var status = results.passed() ? 'passed' : 'failed';
|
||||||
if (results.skipped) {
|
if (results.skipped) {
|
||||||
|
|||||||
@@ -1,192 +0,0 @@
|
|||||||
/* @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); }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (var attr in attrs) {
|
|
||||||
if (attr == "className") {
|
|
||||||
el[attr] = attrs[attr];
|
|
||||||
} else {
|
|
||||||
el.setAttribute(attr, attrs[attr]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return el;
|
|
||||||
};
|
|
||||||
|
|
||||||
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/, '');
|
|
||||||
}
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
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()));
|
|
||||||
};
|
|
||||||
|
|
||||||
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;
|
|
||||||
};
|
|
||||||
|
|
||||||
jasmine.TrivialReporter.prototype.reportSpecStarting = function(spec) {
|
|
||||||
if (this.logRunningSpecs) {
|
|
||||||
this.log('>> Jasmine Running ' + spec.suite.description + ' ' + spec.description + '...');
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
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) {
|
|
||||||
messagesDiv.appendChild(this.createDom('div', {className: 'resultMessage fail'}, result.message));
|
|
||||||
|
|
||||||
if (result.trace.stack) {
|
|
||||||
messagesDiv.appendChild(this.createDom('div', {className: 'stackTrace'}, result.trace.stack));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
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;
|
|
||||||
};
|
|
||||||
@@ -1,169 +0,0 @@
|
|||||||
#TrivialReporter {
|
|
||||||
padding: 8px 13px;
|
|
||||||
position: absolute;
|
|
||||||
top: 0;
|
|
||||||
bottom: 0;
|
|
||||||
left: 0;
|
|
||||||
right: 0;
|
|
||||||
overflow-y: scroll;
|
|
||||||
|
|
||||||
background-color: white;
|
|
||||||
font-family: "Helvetica Neue Light", "Lucida Grande", "Calibri", "Arial", sans-serif;
|
|
||||||
|
|
||||||
a:visited, a {
|
|
||||||
color: #303;
|
|
||||||
}
|
|
||||||
|
|
||||||
a:hover, a:active {
|
|
||||||
color: blue;
|
|
||||||
}
|
|
||||||
|
|
||||||
.run_spec {
|
|
||||||
float:right;
|
|
||||||
padding-right: 5px;
|
|
||||||
font-size: .8em;
|
|
||||||
text-decoration: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.banner {
|
|
||||||
color: #303;
|
|
||||||
background-color: #fef;
|
|
||||||
padding: 5px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.logo {
|
|
||||||
float: left;
|
|
||||||
font-size: 1.1em;
|
|
||||||
padding-left: 5px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.logo .version {
|
|
||||||
font-size: .6em;
|
|
||||||
padding-left: 1em;
|
|
||||||
}
|
|
||||||
|
|
||||||
.runner.running {
|
|
||||||
background-color: yellow;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
.options {
|
|
||||||
text-align: right;
|
|
||||||
font-size: .8em;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
.suite {
|
|
||||||
border: 1px outset gray;
|
|
||||||
margin: 5px 0;
|
|
||||||
padding-left: 1em;
|
|
||||||
}
|
|
||||||
|
|
||||||
.suite .suite {
|
|
||||||
margin: 5px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.suite.passed {
|
|
||||||
background-color: #dfd;
|
|
||||||
}
|
|
||||||
|
|
||||||
.suite.failed {
|
|
||||||
background-color: #fdd;
|
|
||||||
}
|
|
||||||
|
|
||||||
.spec {
|
|
||||||
margin: 5px;
|
|
||||||
padding-left: 1em;
|
|
||||||
clear: both;
|
|
||||||
}
|
|
||||||
|
|
||||||
.spec.failed, .spec.passed, .spec.skipped {
|
|
||||||
padding-bottom: 5px;
|
|
||||||
border: 1px solid gray;
|
|
||||||
}
|
|
||||||
|
|
||||||
.spec.failed {
|
|
||||||
background-color: #fbb;
|
|
||||||
border-color: red;
|
|
||||||
}
|
|
||||||
|
|
||||||
.spec.passed {
|
|
||||||
background-color: #bfb;
|
|
||||||
border-color: green;
|
|
||||||
}
|
|
||||||
|
|
||||||
.spec.skipped {
|
|
||||||
background-color: #bbb;
|
|
||||||
}
|
|
||||||
|
|
||||||
.messages {
|
|
||||||
border-left: 1px dashed gray;
|
|
||||||
padding-left: 1em;
|
|
||||||
padding-right: 1em;
|
|
||||||
}
|
|
||||||
|
|
||||||
.passed {
|
|
||||||
background-color: #cfc;
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.failed {
|
|
||||||
background-color: #fbb;
|
|
||||||
}
|
|
||||||
|
|
||||||
.skipped {
|
|
||||||
color: #777;
|
|
||||||
background-color: #eee;
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*.resultMessage {*/
|
|
||||||
/*white-space: pre;*/
|
|
||||||
/*}*/
|
|
||||||
|
|
||||||
.resultMessage span.result {
|
|
||||||
display: block;
|
|
||||||
line-height: 2em;
|
|
||||||
color: black;
|
|
||||||
}
|
|
||||||
|
|
||||||
.resultMessage .mismatch {
|
|
||||||
color: black;
|
|
||||||
}
|
|
||||||
|
|
||||||
.stackTrace {
|
|
||||||
white-space: pre;
|
|
||||||
font-size: .8em;
|
|
||||||
margin-left: 10px;
|
|
||||||
max-height: 5em;
|
|
||||||
overflow: auto;
|
|
||||||
border: 1px inset red;
|
|
||||||
padding: 1em;
|
|
||||||
background: #eef;
|
|
||||||
}
|
|
||||||
|
|
||||||
.finished-at {
|
|
||||||
padding-left: 1em;
|
|
||||||
font-size: .6em;
|
|
||||||
}
|
|
||||||
|
|
||||||
&.show-passed .passed,
|
|
||||||
&.show-skipped .skipped {
|
|
||||||
display: block;
|
|
||||||
}
|
|
||||||
|
|
||||||
#jasmine_content {
|
|
||||||
position:fixed;
|
|
||||||
right: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.runner {
|
|
||||||
border: 1px solid gray;
|
|
||||||
display: block;
|
|
||||||
margin: 5px 0;
|
|
||||||
padding: 2px 0 2px 10px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -50,33 +50,3 @@ body { background-color: #eeeeee; padding: 0; margin: 5px; overflow-y: scroll; }
|
|||||||
#HTMLReporter .resultMessage { padding-top: 14px; color: #333333; }
|
#HTMLReporter .resultMessage { padding-top: 14px; color: #333333; }
|
||||||
#HTMLReporter .resultMessage span.result { display: block; }
|
#HTMLReporter .resultMessage span.result { display: block; }
|
||||||
#HTMLReporter .stackTrace { margin: 5px 0 0 0; max-height: 224px; overflow: auto; line-height: 18px; color: #666666; border: 1px solid #ddd; background: white; white-space: pre; }
|
#HTMLReporter .stackTrace { margin: 5px 0 0 0; max-height: 224px; overflow: auto; line-height: 18px; color: #666666; border: 1px solid #ddd; background: white; white-space: pre; }
|
||||||
|
|
||||||
#TrivialReporter { padding: 8px 13px; position: absolute; top: 0; bottom: 0; left: 0; right: 0; overflow-y: scroll; background-color: white; font-family: "Helvetica Neue Light", "Lucida Grande", "Calibri", "Arial", sans-serif; /*.resultMessage {*/ /*white-space: pre;*/ /*}*/ }
|
|
||||||
#TrivialReporter a:visited, #TrivialReporter a { color: #303; }
|
|
||||||
#TrivialReporter a:hover, #TrivialReporter a:active { color: blue; }
|
|
||||||
#TrivialReporter .run_spec { float: right; padding-right: 5px; font-size: .8em; text-decoration: none; }
|
|
||||||
#TrivialReporter .banner { color: #303; background-color: #fef; padding: 5px; }
|
|
||||||
#TrivialReporter .logo { float: left; font-size: 1.1em; padding-left: 5px; }
|
|
||||||
#TrivialReporter .logo .version { font-size: .6em; padding-left: 1em; }
|
|
||||||
#TrivialReporter .runner.running { background-color: yellow; }
|
|
||||||
#TrivialReporter .options { text-align: right; font-size: .8em; }
|
|
||||||
#TrivialReporter .suite { border: 1px outset gray; margin: 5px 0; padding-left: 1em; }
|
|
||||||
#TrivialReporter .suite .suite { margin: 5px; }
|
|
||||||
#TrivialReporter .suite.passed { background-color: #dfd; }
|
|
||||||
#TrivialReporter .suite.failed { background-color: #fdd; }
|
|
||||||
#TrivialReporter .spec { margin: 5px; padding-left: 1em; clear: both; }
|
|
||||||
#TrivialReporter .spec.failed, #TrivialReporter .spec.passed, #TrivialReporter .spec.skipped { padding-bottom: 5px; border: 1px solid gray; }
|
|
||||||
#TrivialReporter .spec.failed { background-color: #fbb; border-color: red; }
|
|
||||||
#TrivialReporter .spec.passed { background-color: #bfb; border-color: green; }
|
|
||||||
#TrivialReporter .spec.skipped { background-color: #bbb; }
|
|
||||||
#TrivialReporter .messages { border-left: 1px dashed gray; padding-left: 1em; padding-right: 1em; }
|
|
||||||
#TrivialReporter .passed { background-color: #cfc; display: none; }
|
|
||||||
#TrivialReporter .failed { background-color: #fbb; }
|
|
||||||
#TrivialReporter .skipped { color: #777; background-color: #eee; display: none; }
|
|
||||||
#TrivialReporter .resultMessage span.result { display: block; line-height: 2em; color: black; }
|
|
||||||
#TrivialReporter .resultMessage .mismatch { color: black; }
|
|
||||||
#TrivialReporter .stackTrace { white-space: pre; font-size: .8em; margin-left: 10px; max-height: 5em; overflow: auto; border: 1px inset red; padding: 1em; background: #eef; }
|
|
||||||
#TrivialReporter .finished-at { padding-left: 1em; font-size: .6em; }
|
|
||||||
#TrivialReporter.show-passed .passed, #TrivialReporter.show-skipped .skipped { display: block; }
|
|
||||||
#TrivialReporter #jasmine_content { position: fixed; right: 100%; }
|
|
||||||
#TrivialReporter .runner { border: 1px solid gray; display: block; margin: 5px 0; padding: 2px 0 2px 10px; }
|
|
||||||
|
|||||||
@@ -1,2 +1 @@
|
|||||||
@import "HTMLReporter";
|
@import "HTMLReporter";
|
||||||
@import "TrivialReporter";
|
|
||||||
@@ -27,7 +27,6 @@ class JasmineDev < Thor
|
|||||||
"ReporterView.js",
|
"ReporterView.js",
|
||||||
"SpecView.js",
|
"SpecView.js",
|
||||||
"SuiteView.js",
|
"SuiteView.js",
|
||||||
"TrivialReporter.js"
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user