merge in fixes to TrivialConsoleReporter: correct # of specs, no longer limited by column length
1
.gitignore
vendored
@ -4,3 +4,4 @@
|
||||
site/
|
||||
.bundle/
|
||||
.pairs
|
||||
.rvmrc
|
||||
|
4
Rakefile
@ -33,7 +33,7 @@ task :spec => ["spec:node", "spec:browser", "jasmine:hint"]
|
||||
namespace :spec do
|
||||
desc 'Run specs in Node.js'
|
||||
task :node do
|
||||
system("node spec/node_suite.js")
|
||||
raise "Node is required to run all jasmine specs" unless system("node spec/node_suite.js")
|
||||
end
|
||||
|
||||
desc "Run specs in the default browser (MacOS only)"
|
||||
@ -163,4 +163,4 @@ jasmine.version_= {
|
||||
exec "cd #{temp_dir} && zip -r #{zip_file_name} . -x .[a-zA-Z0-9]*"
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
Before Width: | Height: | Size: 722 B |
BIN
images/fail.png
Before Width: | Height: | Size: 2.1 KiB |
BIN
images/go-16.png
Before Width: | Height: | Size: 759 B |
BIN
images/go.png
Before Width: | Height: | Size: 2.2 KiB |
BIN
images/jasmine_favicon.png
Normal file
After Width: | Height: | Size: 905 B |
Before Width: | Height: | Size: 802 B |
Before Width: | Height: | Size: 2.7 KiB |
Before Width: | Height: | Size: 2.5 KiB |
Before Width: | Height: | Size: 768 B |
Before Width: | Height: | Size: 1.7 KiB |
304
lib/jasmine.css
@ -1,14 +1,24 @@
|
||||
body {
|
||||
font-family: "Helvetica Neue Light", "Lucida Grande", "Calibri", "Arial", sans-serif;
|
||||
margin: 0;
|
||||
background-color: #f0f0f0;
|
||||
}
|
||||
|
||||
|
||||
.jasmine_reporter a:visited, .jasmine_reporter a {
|
||||
color: #303;
|
||||
a {
|
||||
text-decoration: none;
|
||||
color: #777;
|
||||
}
|
||||
|
||||
.jasmine_reporter a:hover, .jasmine_reporter a:active {
|
||||
color: blue;
|
||||
a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.description {
|
||||
display: block;
|
||||
padding: .4em 0 .4em 1.5em;
|
||||
font-size: .8em;
|
||||
min-height: 1.2em;
|
||||
line-height: 1.2em;
|
||||
}
|
||||
|
||||
.run_spec {
|
||||
@ -16,111 +26,240 @@ body {
|
||||
padding-right: 5px;
|
||||
font-size: .8em;
|
||||
text-decoration: none;
|
||||
display: none;
|
||||
}
|
||||
|
||||
.jasmine_reporter {
|
||||
margin: 0 5px;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.banner {
|
||||
color: #303;
|
||||
background-color: #fef;
|
||||
padding: 5px;
|
||||
padding: 0 1.5em;
|
||||
height: 1.2em;
|
||||
line-height: 1.2em;
|
||||
}
|
||||
|
||||
.logo {
|
||||
float: left;
|
||||
font-size: 1.1em;
|
||||
font-size: .8em;
|
||||
padding-left: 5px;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.logo .version {
|
||||
font-size: .6em;
|
||||
padding-left: 1em;
|
||||
font-size: .8em;
|
||||
padding-left: .5em;
|
||||
color: gray;
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
.runner.running {
|
||||
background-color: yellow;
|
||||
}
|
||||
|
||||
|
||||
.options {
|
||||
text-align: right;
|
||||
font-size: .8em;
|
||||
font-size: .6em;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
.suite {
|
||||
border: 1px outset gray;
|
||||
margin: 5px 0;
|
||||
padding-left: 1em;
|
||||
position: relative;
|
||||
margin: 10px 1.5em;
|
||||
padding-bottom: 3px;
|
||||
-moz-border-radius: 6px;
|
||||
border-radius: 6px;
|
||||
-moz-box-shadow: 0px 1px 4px #200;
|
||||
-webkit-box-shadow: 0px 1px 4px #200;
|
||||
box-shadow: 0px 1px 4px #200;
|
||||
background-color: #ddd;
|
||||
}
|
||||
|
||||
.suite .suite {
|
||||
margin: 5px;
|
||||
-moz-border-radius: 3px;
|
||||
border-radius: 3px;
|
||||
|
||||
}
|
||||
|
||||
.suite > .description {
|
||||
padding-left: 1.2em;
|
||||
|
||||
border-bottom: 1px solid gray;
|
||||
-moz-border-radius-topleft: 6px;
|
||||
-moz-border-radius-topright: 6px;
|
||||
border-top-left-radius: 6px;
|
||||
border-top-right-radius: 6px;
|
||||
|
||||
background-image: -webkit-gradient(
|
||||
linear,
|
||||
left bottom,
|
||||
left top,
|
||||
color-stop(0.1, rgb(186,186,186)),
|
||||
color-stop(0.9, rgb(240,240,240))
|
||||
);
|
||||
background-image: -moz-linear-gradient(
|
||||
center bottom,
|
||||
rgb(186,186,186) 10%,
|
||||
rgb(240,240,240) 90%
|
||||
);
|
||||
}
|
||||
|
||||
.suite .suite>.description {
|
||||
-moz-border-radius-topleft: 3px;
|
||||
-moz-border-radius-topright: 3px;
|
||||
border-top-left-radius: 3px;
|
||||
border-top-right-radius: 3px;
|
||||
}
|
||||
|
||||
.suite.passed {
|
||||
background-color: #dfd;
|
||||
border-color: #bbb;
|
||||
}
|
||||
|
||||
.suite.failed {
|
||||
background-color: #fdd;
|
||||
border-color: #fcc;
|
||||
}
|
||||
|
||||
.suite > .description {
|
||||
font-weight: 700;
|
||||
font-size: 1em;
|
||||
text-shadow: 0px 1px 0px #eee;
|
||||
color: #777;
|
||||
}
|
||||
|
||||
.suite.passed > .description {
|
||||
color: rgb(94,125,0);
|
||||
text-shadow: 0px 1px 0px #ddd;
|
||||
}
|
||||
|
||||
.suite.failed > .description {
|
||||
color: rgb(176,57,17);
|
||||
}
|
||||
|
||||
.spec {
|
||||
margin: 5px;
|
||||
padding-left: 1em;
|
||||
margin: 0;
|
||||
clear: both;
|
||||
position: relative;
|
||||
padding-bottom: 0;
|
||||
border-bottom: 1px solid gray;
|
||||
}
|
||||
|
||||
.spec.failed, .spec.passed, .spec.skipped {
|
||||
padding-bottom: 5px;
|
||||
border: 1px solid gray;
|
||||
|
||||
}
|
||||
|
||||
.spec.failed:first-child, .spec.passed:first-child, .spec.skipped:first-child {
|
||||
}
|
||||
|
||||
.spec.failed {
|
||||
background-color: #fbb;
|
||||
border-color: red;
|
||||
background-color: white;
|
||||
}
|
||||
|
||||
.spec > .description {
|
||||
color: #666;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.spec.failed > .description {
|
||||
color: white;
|
||||
|
||||
background-image: -webkit-gradient(
|
||||
linear,
|
||||
left bottom,
|
||||
left top,
|
||||
color-stop(0.1, rgb(176,57,17)),
|
||||
color-stop(0.94, rgb(237,87,0))
|
||||
);
|
||||
background-image: -moz-linear-gradient(
|
||||
center bottom,
|
||||
rgb(176,57,17) 10%,
|
||||
rgb(237,87,0) 94%
|
||||
);
|
||||
}
|
||||
|
||||
.spec.failed > .description:before {
|
||||
display: block;
|
||||
position: absolute;
|
||||
left: 5px;
|
||||
top: 8px;
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
content: ".";
|
||||
color: transparent;
|
||||
border: 1px solid #ffffff;
|
||||
|
||||
-moz-border-radius: 5px;
|
||||
|
||||
background-image: -webkit-gradient(
|
||||
linear,
|
||||
left bottom,
|
||||
left top,
|
||||
color-stop(0.1, rgb(176,57,17)),
|
||||
color-stop(0.94, rgb(237,87,0))
|
||||
);
|
||||
background-image: -moz-linear-gradient(
|
||||
center bottom,
|
||||
rgb(176,57,17) 10%,
|
||||
rgb(237,87,0) 94%
|
||||
);
|
||||
}
|
||||
|
||||
.spec.passed {
|
||||
background-color: #bfb;
|
||||
border-color: green;
|
||||
background-color: white;
|
||||
border-color: #bbb;
|
||||
}
|
||||
|
||||
.spec.passed>.description {
|
||||
background-color: #ddd;
|
||||
}
|
||||
|
||||
.spec.passed>.description:before {
|
||||
display: block;
|
||||
position: absolute;
|
||||
left: 6px;
|
||||
top: 9px;
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
content: ".";
|
||||
color: transparent;
|
||||
|
||||
-moz-border-radius: 4px;
|
||||
|
||||
background-image: -webkit-gradient(
|
||||
linear,
|
||||
left bottom,
|
||||
left top,
|
||||
color-stop(0.1, rgb(94,125,0)),
|
||||
color-stop(0.9, rgb(167,212,21))
|
||||
);
|
||||
background-image: -moz-linear-gradient(
|
||||
center bottom,
|
||||
rgb(94,125,0) 10%,
|
||||
rgb(167,212,21) 90%
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
.spec.skipped {
|
||||
background-color: #bbb;
|
||||
}
|
||||
|
||||
|
||||
.messages {
|
||||
border-left: 1px dashed gray;
|
||||
padding-left: 1em;
|
||||
padding-right: 1em;
|
||||
font-size: .8em;
|
||||
padding: 5px 1.5em 0 1.5em;
|
||||
line-height: 1.2em;
|
||||
}
|
||||
|
||||
.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;
|
||||
@ -132,14 +271,22 @@ body {
|
||||
}
|
||||
|
||||
.stackTrace {
|
||||
white-space: pre;
|
||||
font-size: .8em;
|
||||
margin-left: 10px;
|
||||
padding: 5px 1em;
|
||||
margin: 5px 0;
|
||||
max-height: 5em;
|
||||
overflow: auto;
|
||||
border: 1px inset red;
|
||||
padding: 1em;
|
||||
overflow: hidden;
|
||||
|
||||
border: 1px solid #baa;
|
||||
background: #eef;
|
||||
|
||||
white-space: pre;
|
||||
font-size: 1.2em;
|
||||
line-height: 1.5em;
|
||||
font-family: monospace;
|
||||
}
|
||||
|
||||
.stackTrace:hover {
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.finished-at {
|
||||
@ -152,15 +299,64 @@ body {
|
||||
display: block;
|
||||
}
|
||||
|
||||
|
||||
#jasmine_content {
|
||||
position:fixed;
|
||||
position: fixed;
|
||||
right: 100%;
|
||||
}
|
||||
|
||||
.runner {
|
||||
border: 1px solid gray;
|
||||
display: block;
|
||||
margin: 5px 0;
|
||||
padding: 2px 0 2px 10px;
|
||||
margin: 5px 0 10px 0;
|
||||
padding: 2px 0 2px 1.5em;
|
||||
|
||||
border-top: 1px solid gray;
|
||||
-moz-box-shadow: 0px 1px 4px #000;
|
||||
-webkit-box-shadow: 0px 1px 4px #000;
|
||||
box-shadow: 0px 1px 4px #000;
|
||||
|
||||
font-size: .8em;
|
||||
}
|
||||
|
||||
.runner.failed {
|
||||
background-image: -webkit-gradient(
|
||||
linear,
|
||||
left bottom,
|
||||
left top,
|
||||
color-stop(0.1, rgb(176,57,17)),
|
||||
color-stop(0.94, rgb(237,87,0))
|
||||
);
|
||||
background-image: -moz-linear-gradient(
|
||||
center bottom,
|
||||
rgb(176,57,17) 10%,
|
||||
rgb(237,87,0) 94%
|
||||
);
|
||||
}
|
||||
|
||||
.runner.passed {
|
||||
|
||||
background-image: -webkit-gradient(
|
||||
linear,
|
||||
left bottom,
|
||||
left top,
|
||||
color-stop(0.1, rgb(94,125,0)),
|
||||
color-stop(0.9, rgb(167,212,21))
|
||||
);
|
||||
background-image: -moz-linear-gradient(
|
||||
center bottom,
|
||||
rgb(94,125,0) 10%,
|
||||
rgb(167,212,21) 90%
|
||||
);
|
||||
}
|
||||
|
||||
.runner .description {
|
||||
padding-left: .8em;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.runner.running {
|
||||
background-color: yellow;
|
||||
}
|
||||
|
||||
.runner>.description {
|
||||
height: 1em;
|
||||
}
|
@ -22,6 +22,12 @@ jasmine.unimplementedMethod_ = function() {
|
||||
*/
|
||||
jasmine.undefined = jasmine.___undefined___;
|
||||
|
||||
/**
|
||||
* Show diagnostic messages in the console if set to true
|
||||
*
|
||||
*/
|
||||
jasmine.VERBOSE = false;
|
||||
|
||||
/**
|
||||
* Default interval in milliseconds for event loop yields (e.g. to allow network activity or to refresh the screen with the HTML-based runner). Small values here may result in slow test running. Zero means no updates until all tests have completed.
|
||||
*
|
||||
@ -773,14 +779,14 @@ jasmine.Env.prototype.describe = function(description, specDefinitions) {
|
||||
declarationError = e;
|
||||
}
|
||||
|
||||
this.currentSuite = parentSuite;
|
||||
|
||||
if (declarationError) {
|
||||
this.it("encountered a declaration exception", function() {
|
||||
throw declarationError;
|
||||
});
|
||||
}
|
||||
|
||||
this.currentSuite = parentSuite;
|
||||
|
||||
return suite;
|
||||
};
|
||||
|
||||
@ -1379,6 +1385,23 @@ jasmine.Matchers.prototype.toBeGreaterThan = function(expected) {
|
||||
return this.actual > expected;
|
||||
};
|
||||
|
||||
/**
|
||||
* Matcher that checks that the expected item is equal to the actual item
|
||||
* up to a given level of decimal precision (default 2).
|
||||
*
|
||||
* @param {Number} expected
|
||||
* @param {Number} precision
|
||||
*/
|
||||
jasmine.Matchers.prototype.toBeCloseTo = function(expected, precision) {
|
||||
if (!(precision === 0)) {
|
||||
precision = precision || 2;
|
||||
}
|
||||
var multiplier = Math.pow(10, precision);
|
||||
var actual = Math.round(this.actual * multiplier);
|
||||
expected = Math.round(expected * multiplier);
|
||||
return expected == actual;
|
||||
};
|
||||
|
||||
/**
|
||||
* Matcher that checks that the expected exception was thrown by the actual.
|
||||
*
|
||||
@ -2186,7 +2209,9 @@ jasmine.WaitsBlock = function(env, timeout, spec) {
|
||||
jasmine.util.inherit(jasmine.WaitsBlock, jasmine.Block);
|
||||
|
||||
jasmine.WaitsBlock.prototype.execute = function (onComplete) {
|
||||
this.env.reporter.log('>> Jasmine waiting for ' + this.timeout + ' ms...');
|
||||
if (jasmine.VERBOSE) {
|
||||
this.env.reporter.log('>> Jasmine waiting for ' + this.timeout + ' ms...');
|
||||
}
|
||||
this.env.setTimeout(function () {
|
||||
onComplete();
|
||||
}, this.timeout);
|
||||
@ -2214,7 +2239,9 @@ jasmine.util.inherit(jasmine.WaitsForBlock, jasmine.Block);
|
||||
jasmine.WaitsForBlock.TIMEOUT_INCREMENT = 10;
|
||||
|
||||
jasmine.WaitsForBlock.prototype.execute = function(onComplete) {
|
||||
this.env.reporter.log('>> Jasmine waiting for ' + (this.message || 'something to happen'));
|
||||
if (jasmine.VERBOSE) {
|
||||
this.env.reporter.log('>> Jasmine waiting for ' + (this.message || 'something to happen'));
|
||||
}
|
||||
var latchFunctionResult;
|
||||
try {
|
||||
latchFunctionResult = this.latchFunction.apply(this.spec);
|
||||
@ -2431,5 +2458,5 @@ jasmine.version_= {
|
||||
"major": 1,
|
||||
"minor": 1,
|
||||
"build": 0,
|
||||
"revision": 1299963843
|
||||
"revision": 1306336386
|
||||
};
|
||||
|
@ -8,7 +8,7 @@
|
||||
// yes, really keep this here to keep us honest, but only for jasmine's own runner! [xw]
|
||||
undefined = "diz be undefined yo";
|
||||
</script>
|
||||
|
||||
<link rel="shortcut icon" type="image/png" href="../images/jasmine_favicon.png">
|
||||
<script type="text/javascript" src="../src/base.js"></script>
|
||||
<script type="text/javascript" src="../src/util.js"></script>
|
||||
<script type="text/javascript" src="../src/Env.js"></script>
|
||||
@ -79,4 +79,4 @@
|
||||
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
|
@ -1,429 +1,431 @@
|
||||
describe("TrivialConsoleReporter", function() {
|
||||
|
||||
if (jasmine.TrivialConsoleReporter) {
|
||||
describe("TrivialConsoleReporter", function() {
|
||||
|
||||
//keep these literal. otherwise the test loses value as a test.
|
||||
function green(str) { return '\033[32m' + str + '\033[0m'; }
|
||||
function red(str) { return '\033[31m' + str + '\033[0m'; }
|
||||
function yellow(str) { return '\033[33m' + str + '\033[0m'; }
|
||||
|
||||
function prefixGreen(str) { return '\033[32m' + str; }
|
||||
function prefixRed(str) { return '\033[31m' + str; }
|
||||
|
||||
var newline = "\n";
|
||||
|
||||
var passingSpec = { results: function(){ return {passed: function(){return true;}}; } },
|
||||
failingSpec = { results: function(){ return {passed: function(){return false;}}; } },
|
||||
skippedSpec = { results: function(){ return {skipped: true}; } },
|
||||
passingRun = { results: function(){ return {failedCount: 0, items_: [null, null, null]}; } },
|
||||
failingRun = { results: function(){ return {failedCount: 7, items_: [null, null, null]}; } };
|
||||
|
||||
function repeatedlyInvoke(f, times) { for(var i=0; i<times; i++) f(times+1); }
|
||||
|
||||
function repeat(thing, times) {
|
||||
var arr = [];
|
||||
for(var i=0; i<times; i++) arr.push(thing);
|
||||
return arr;
|
||||
}
|
||||
|
||||
var fiftyRedFs = repeat(red("F"), 50).join(""),
|
||||
fiftyGreenDots = repeat(green("."), 50).join("");
|
||||
|
||||
function simulateRun(reporter, specResults, suiteResults, finalRunner, startTime, endTime) {
|
||||
reporter.reportRunnerStarting();
|
||||
for(var i=0; i<specResults.length; i++) reporter.reportSpecResults(specResults[i]);
|
||||
for(i=0; i<suiteResults.length; i++) reporter.reportSuiteResults(suiteResults[i]);
|
||||
reporter.runnerStartTime = startTime;
|
||||
reporter.now = function(){return endTime;};
|
||||
reporter.reportRunnerResults(finalRunner);
|
||||
}
|
||||
|
||||
beforeEach(function() {
|
||||
this.out = (function(){
|
||||
var output = "";
|
||||
return {
|
||||
print:function(str) {output += str;},
|
||||
getOutput:function(){return output;},
|
||||
clear: function(){output = "";}
|
||||
};
|
||||
})();
|
||||
|
||||
this.done = false
|
||||
var self = this
|
||||
this.reporter = new jasmine.TrivialConsoleReporter(this.out.print, function(runner){
|
||||
self.done = true
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
describe('Integration', function(){
|
||||
it("prints the proper output under a pass scenario. small numbers.", function(){
|
||||
simulateRun(this.reporter,
|
||||
repeat(passingSpec, 3),
|
||||
[],
|
||||
{
|
||||
results:function(){
|
||||
return {
|
||||
items_: [null, null, null],
|
||||
totalCount: 7,
|
||||
failedCount: 0
|
||||
};
|
||||
}
|
||||
},
|
||||
1000,
|
||||
1777);
|
||||
|
||||
expect(this.out.getOutput()).toEqual(
|
||||
[
|
||||
"Started",
|
||||
green(".") + green(".") + green("."),
|
||||
"",
|
||||
"Finished in 0.777 seconds",
|
||||
green("3 specs, 7 expectations, 0 failures"),
|
||||
""
|
||||
].join("\n") + "\n"
|
||||
);
|
||||
//keep these literal. otherwise the test loses value as a test.
|
||||
function green(str) { return '\033[32m' + str + '\033[0m'; }
|
||||
function red(str) { return '\033[31m' + str + '\033[0m'; }
|
||||
function yellow(str) { return '\033[33m' + str + '\033[0m'; }
|
||||
|
||||
function prefixGreen(str) { return '\033[32m' + str; }
|
||||
function prefixRed(str) { return '\033[31m' + str; }
|
||||
|
||||
var newline = "\n";
|
||||
|
||||
var passingSpec = { results: function(){ return {passed: function(){return true;}}; } },
|
||||
failingSpec = { results: function(){ return {passed: function(){return false;}}; } },
|
||||
skippedSpec = { results: function(){ return {skipped: true}; } },
|
||||
passingRun = { results: function(){ return {failedCount: 0, items_: [null, null, null]}; } },
|
||||
failingRun = { results: function(){ return {failedCount: 7, items_: [null, null, null]}; } };
|
||||
|
||||
function repeatedlyInvoke(f, times) { for(var i=0; i<times; i++) f(times+1); }
|
||||
|
||||
function repeat(thing, times) {
|
||||
var arr = [];
|
||||
for(var i=0; i<times; i++) arr.push(thing);
|
||||
return arr;
|
||||
}
|
||||
|
||||
var fiftyRedFs = repeat(red("F"), 50).join(""),
|
||||
fiftyGreenDots = repeat(green("."), 50).join("");
|
||||
|
||||
function simulateRun(reporter, specResults, suiteResults, finalRunner, startTime, endTime) {
|
||||
reporter.reportRunnerStarting();
|
||||
for(var i=0; i<specResults.length; i++) reporter.reportSpecResults(specResults[i]);
|
||||
for(i=0; i<suiteResults.length; i++) reporter.reportSuiteResults(suiteResults[i]);
|
||||
reporter.runnerStartTime = startTime;
|
||||
reporter.now = function(){return endTime;};
|
||||
reporter.reportRunnerResults(finalRunner);
|
||||
}
|
||||
|
||||
beforeEach(function() {
|
||||
this.out = (function(){
|
||||
var output = "";
|
||||
return {
|
||||
print:function(str) {output += str;},
|
||||
getOutput:function(){return output;},
|
||||
clear: function(){output = "";}
|
||||
};
|
||||
})();
|
||||
|
||||
this.done = false
|
||||
var self = this
|
||||
this.reporter = new jasmine.TrivialConsoleReporter(this.out.print, function(runner){
|
||||
self.done = true
|
||||
});
|
||||
});
|
||||
|
||||
it("prints the proper output under a pass scenario. large numbers.", function(){
|
||||
simulateRun(this.reporter,
|
||||
repeat(passingSpec, 57),
|
||||
[],
|
||||
{
|
||||
results:function(){
|
||||
return {
|
||||
items_: [null, null, null],
|
||||
totalCount: 7,
|
||||
failedCount: 0
|
||||
};
|
||||
}
|
||||
},
|
||||
1000,
|
||||
1777);
|
||||
|
||||
expect(this.out.getOutput()).toEqual(
|
||||
[
|
||||
"Started",
|
||||
|
||||
green(".") + green(".") + green(".") + green(".") + green(".") + //50 green dots
|
||||
green(".") + green(".") + green(".") + green(".") + green(".") +
|
||||
green(".") + green(".") + green(".") + green(".") + green(".") +
|
||||
green(".") + green(".") + green(".") + green(".") + green(".") +
|
||||
green(".") + green(".") + green(".") + green(".") + green(".") +
|
||||
green(".") + green(".") + green(".") + green(".") + green(".") +
|
||||
green(".") + green(".") + green(".") + green(".") + green(".") +
|
||||
green(".") + green(".") + green(".") + green(".") + green(".") +
|
||||
green(".") + green(".") + green(".") + green(".") + green(".") +
|
||||
green(".") + green(".") + green(".") + green(".") + green(".") + newline +
|
||||
|
||||
green(".") + green(".") + green(".") + green(".") + green(".") + //7 green dots
|
||||
green(".") + green("."),
|
||||
|
||||
"",
|
||||
"Finished in 0.777 seconds",
|
||||
green("3 specs, 7 expectations, 0 failures"),
|
||||
""
|
||||
].join("\n") + "\n"
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
it("prints the proper output under a failure scenario.", function(){
|
||||
simulateRun(this.reporter,
|
||||
[failingSpec, passingSpec, failingSpec],
|
||||
[{description:"The oven",
|
||||
results:function(){
|
||||
return {
|
||||
items_:[
|
||||
{failedCount:2,
|
||||
description:"heats up",
|
||||
|
||||
describe('Integration', function(){
|
||||
it("prints the proper output under a pass scenario. small numbers.", function(){
|
||||
simulateRun(this.reporter,
|
||||
repeat(passingSpec, 3),
|
||||
[],
|
||||
{
|
||||
results:function(){
|
||||
return {
|
||||
items_: [null, null, null],
|
||||
totalCount: 7,
|
||||
failedCount: 0
|
||||
};
|
||||
}
|
||||
},
|
||||
1000,
|
||||
1777);
|
||||
|
||||
expect(this.out.getOutput()).toEqual(
|
||||
[
|
||||
"Started",
|
||||
green(".") + green(".") + green("."),
|
||||
"",
|
||||
"Finished in 0.777 seconds",
|
||||
green("3 specs, 7 expectations, 0 failures"),
|
||||
""
|
||||
].join("\n") + "\n"
|
||||
);
|
||||
});
|
||||
|
||||
it("prints the proper output under a pass scenario. large numbers.", function(){
|
||||
simulateRun(this.reporter,
|
||||
repeat(passingSpec, 57),
|
||||
[],
|
||||
{
|
||||
results:function(){
|
||||
return {
|
||||
items_: [null, null, null],
|
||||
totalCount: 7,
|
||||
failedCount: 0
|
||||
};
|
||||
}
|
||||
},
|
||||
1000,
|
||||
1777);
|
||||
|
||||
expect(this.out.getOutput()).toEqual(
|
||||
[
|
||||
"Started",
|
||||
|
||||
green(".") + green(".") + green(".") + green(".") + green(".") + //50 green dots
|
||||
green(".") + green(".") + green(".") + green(".") + green(".") +
|
||||
green(".") + green(".") + green(".") + green(".") + green(".") +
|
||||
green(".") + green(".") + green(".") + green(".") + green(".") +
|
||||
green(".") + green(".") + green(".") + green(".") + green(".") +
|
||||
green(".") + green(".") + green(".") + green(".") + green(".") +
|
||||
green(".") + green(".") + green(".") + green(".") + green(".") +
|
||||
green(".") + green(".") + green(".") + green(".") + green(".") +
|
||||
green(".") + green(".") + green(".") + green(".") + green(".") +
|
||||
green(".") + green(".") + green(".") + green(".") + green(".") + newline +
|
||||
|
||||
green(".") + green(".") + green(".") + green(".") + green(".") + //7 green dots
|
||||
green(".") + green("."),
|
||||
|
||||
"",
|
||||
"Finished in 0.777 seconds",
|
||||
green("3 specs, 7 expectations, 0 failures"),
|
||||
""
|
||||
].join("\n") + "\n"
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
it("prints the proper output under a failure scenario.", function(){
|
||||
simulateRun(this.reporter,
|
||||
[failingSpec, passingSpec, failingSpec],
|
||||
[{description:"The oven",
|
||||
results:function(){
|
||||
return {
|
||||
items_:[
|
||||
{failedCount:2,
|
||||
description:"heats up",
|
||||
items_:[
|
||||
{trace:{stack:"stack trace one\n second line"}},
|
||||
{trace:{stack:"stack trace two"}}
|
||||
]}
|
||||
]
|
||||
};
|
||||
}},
|
||||
{description:"The washing machine",
|
||||
results:function(){
|
||||
return {
|
||||
items_:[
|
||||
{trace:{stack:"stack trace one\n second line"}},
|
||||
{trace:{stack:"stack trace two"}}
|
||||
]}
|
||||
]
|
||||
};
|
||||
}},
|
||||
{description:"The washing machine",
|
||||
results:function(){
|
||||
return {
|
||||
items_:[
|
||||
{failedCount:2,
|
||||
description:"washes clothes",
|
||||
items_:[
|
||||
{trace:{stack:"stack trace one"}}
|
||||
]}
|
||||
]
|
||||
};
|
||||
}}
|
||||
],
|
||||
{
|
||||
results:function(){
|
||||
return {
|
||||
items_: [null, null, null],
|
||||
totalCount: 7,
|
||||
failedCount: 2
|
||||
};
|
||||
}
|
||||
},
|
||||
1000,
|
||||
1777);
|
||||
|
||||
expect(this.out.getOutput()).toEqual(
|
||||
[
|
||||
"Started",
|
||||
red("F") + green(".") + red("F"),
|
||||
"",
|
||||
"The oven heats up",
|
||||
" stack trace one",
|
||||
" second line",
|
||||
" stack trace two",
|
||||
"",
|
||||
"The washing machine washes clothes",
|
||||
" stack trace one",
|
||||
"",
|
||||
"Finished in 0.777 seconds",
|
||||
red("3 specs, 7 expectations, 2 failures"),
|
||||
""
|
||||
].join("\n") + "\n"
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
describe('A Test Run', function(){
|
||||
|
||||
describe('Starts', function(){
|
||||
it("prints Started", function(){
|
||||
this.reporter.reportRunnerStarting();
|
||||
{failedCount:2,
|
||||
description:"washes clothes",
|
||||
items_:[
|
||||
{trace:{stack:"stack trace one"}}
|
||||
]}
|
||||
]
|
||||
};
|
||||
}}
|
||||
],
|
||||
{
|
||||
results:function(){
|
||||
return {
|
||||
items_: [null, null, null],
|
||||
totalCount: 7,
|
||||
failedCount: 2
|
||||
};
|
||||
}
|
||||
},
|
||||
1000,
|
||||
1777);
|
||||
|
||||
expect(this.out.getOutput()).toEqual(
|
||||
"Started" + newline
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('A spec runs', function(){
|
||||
it("prints a green dot if the spec passes", function(){
|
||||
this.reporter.reportSpecResults(passingSpec);
|
||||
|
||||
expect(this.out.getOutput()).toEqual(
|
||||
green(".")
|
||||
);
|
||||
});
|
||||
|
||||
it("prints a red dot if the spec fails", function(){
|
||||
this.reporter.reportSpecResults(failingSpec);
|
||||
|
||||
expect(this.out.getOutput()).toEqual(
|
||||
red("F")
|
||||
[
|
||||
"Started",
|
||||
red("F") + green(".") + red("F"),
|
||||
"",
|
||||
"The oven heats up",
|
||||
" stack trace one",
|
||||
" second line",
|
||||
" stack trace two",
|
||||
"",
|
||||
"The washing machine washes clothes",
|
||||
" stack trace one",
|
||||
"",
|
||||
"Finished in 0.777 seconds",
|
||||
red("3 specs, 7 expectations, 2 failures"),
|
||||
""
|
||||
].join("\n") + "\n"
|
||||
);
|
||||
});
|
||||
|
||||
it("prints a yellow star if the spec was skipped", function(){
|
||||
this.reporter.reportSpecResults(skippedSpec);
|
||||
|
||||
expect(this.out.getOutput()).toEqual(
|
||||
yellow("*")
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
describe('Many specs run', function(){
|
||||
it("starts a new line every 50 specs", function(){
|
||||
var self = this;
|
||||
repeatedlyInvoke(function(){self.reporter.reportSpecResults(failingSpec);}, 49);
|
||||
|
||||
expect(this.out.getOutput()).
|
||||
toEqual(repeat(red("F"), 49).join(""));
|
||||
|
||||
repeatedlyInvoke(function(){self.reporter.reportSpecResults(failingSpec);}, 3);
|
||||
|
||||
expect(this.out.getOutput()).
|
||||
toEqual(fiftyRedFs + newline +
|
||||
red("F") + red("F"));
|
||||
|
||||
repeatedlyInvoke(function(){self.reporter.reportSpecResults(failingSpec);}, 48);
|
||||
repeatedlyInvoke(function(){self.reporter.reportSpecResults(passingSpec);}, 2);
|
||||
|
||||
expect(this.out.getOutput()).
|
||||
toEqual(fiftyRedFs + newline +
|
||||
fiftyRedFs + newline +
|
||||
green(".") + green("."));
|
||||
});
|
||||
});
|
||||
|
||||
describe('A suite runs', function(){
|
||||
it("remembers suite results", function(){
|
||||
var emptyResults = function(){return {items_:[]};};
|
||||
this.reporter.reportSuiteResults({description:"Oven", results:emptyResults});
|
||||
this.reporter.reportSuiteResults({description:"Mixer", results:emptyResults});
|
||||
|
||||
var self = this;
|
||||
var descriptions = [];
|
||||
for(var i=0; i<self.reporter.suiteResults.length; i++)
|
||||
descriptions.push(self.reporter.suiteResults[i].description);
|
||||
|
||||
expect(descriptions).toEqual(["Oven", "Mixer"]);
|
||||
});
|
||||
describe('A Test Run', function(){
|
||||
|
||||
it("creates a description out of the current suite and any parent suites", function(){
|
||||
var emptyResults = function(){return {items_:[]};};
|
||||
var grandparentSuite = {description:"My house", results:emptyResults};
|
||||
var parentSuite = {description:"kitchen", parentSuite: grandparentSuite, results:emptyResults};
|
||||
this.reporter.reportSuiteResults({description:"oven", parentSuite: parentSuite, results:emptyResults});
|
||||
|
||||
expect(this.reporter.suiteResults[0].description).toEqual("My house kitchen oven");
|
||||
});
|
||||
|
||||
it("gathers failing spec results from the suite. the spec must have a description.", function(){
|
||||
this.reporter.reportSuiteResults({description:"Oven",
|
||||
results:function(){
|
||||
return {
|
||||
items_:[
|
||||
{failedCount:0, description:"specOne"},
|
||||
{failedCount:99, description:"specTwo"},
|
||||
{failedCount:0, description:"specThree"},
|
||||
{failedCount:88, description:"specFour"},
|
||||
{failedCount:3}
|
||||
]
|
||||
};
|
||||
}});
|
||||
|
||||
expect(this.reporter.suiteResults[0].failedSpecResults).
|
||||
toEqual([
|
||||
{failedCount:99, description:"specTwo"},
|
||||
{failedCount:88, description:"specFour"}
|
||||
]);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('Finishes', function(){
|
||||
|
||||
describe('Spec failure information', function(){
|
||||
|
||||
it("prints suite and spec descriptions together as a sentence", function(){
|
||||
this.reporter.suiteResults = [
|
||||
{description:"The oven", failedSpecResults:[
|
||||
{description:"heats up", items_:[]},
|
||||
{description:"cleans itself", items_:[]}
|
||||
]},
|
||||
{description:"The mixer", failedSpecResults:[
|
||||
{description:"blends things together", items_:[]}
|
||||
]}
|
||||
];
|
||||
|
||||
this.reporter.reportRunnerResults(failingRun);
|
||||
|
||||
expect(this.out.getOutput()).toContain("The oven heats up");
|
||||
expect(this.out.getOutput()).toContain("The oven cleans itself");
|
||||
expect(this.out.getOutput()).toContain("The mixer blends things together");
|
||||
});
|
||||
|
||||
it("prints stack trace of spec failure", function(){
|
||||
this.reporter.suiteResults = [
|
||||
{description:"The oven", failedSpecResults:[
|
||||
{description:"heats up",
|
||||
items_:[
|
||||
{trace:{stack:"stack trace one"}},
|
||||
{trace:{stack:"stack trace two"}}
|
||||
]}
|
||||
]}
|
||||
];
|
||||
|
||||
this.reporter.reportRunnerResults(failingRun);
|
||||
|
||||
expect(this.out.getOutput()).toContain("The oven heats up");
|
||||
expect(this.out.getOutput()).toContain("stack trace one");
|
||||
expect(this.out.getOutput()).toContain("stack trace two");
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('Finished line', function(){
|
||||
|
||||
it("prints the elapsed time in the summary message", function(){
|
||||
this.reporter.now = function(){return 1000;};
|
||||
describe('Starts', function(){
|
||||
it("prints Started", function(){
|
||||
this.reporter.reportRunnerStarting();
|
||||
this.reporter.now = function(){return 1777;};
|
||||
this.reporter.reportRunnerResults(passingRun);
|
||||
expect(this.out.getOutput()).toContain("0.777 seconds");
|
||||
|
||||
expect(this.out.getOutput()).toEqual(
|
||||
"Started" + newline
|
||||
);
|
||||
});
|
||||
|
||||
it("prints round time numbers correctly", function(){
|
||||
});
|
||||
|
||||
describe('A spec runs', function(){
|
||||
it("prints a green dot if the spec passes", function(){
|
||||
this.reporter.reportSpecResults(passingSpec);
|
||||
|
||||
expect(this.out.getOutput()).toEqual(
|
||||
green(".")
|
||||
);
|
||||
});
|
||||
|
||||
it("prints a red dot if the spec fails", function(){
|
||||
this.reporter.reportSpecResults(failingSpec);
|
||||
|
||||
expect(this.out.getOutput()).toEqual(
|
||||
red("F")
|
||||
);
|
||||
});
|
||||
|
||||
it("prints a yellow star if the spec was skipped", function(){
|
||||
this.reporter.reportSpecResults(skippedSpec);
|
||||
|
||||
expect(this.out.getOutput()).toEqual(
|
||||
yellow("*")
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
describe('Many specs run', function(){
|
||||
it("starts a new line every 50 specs", function(){
|
||||
var self = this;
|
||||
function run(startTime, endTime) {
|
||||
self.out.clear();
|
||||
self.reporter.runnerStartTime = startTime;
|
||||
self.reporter.now = function(){return endTime;};
|
||||
self.reporter.reportRunnerResults(passingRun);
|
||||
}
|
||||
|
||||
run(1000, 11000);
|
||||
expect(this.out.getOutput()).toContain("10 seconds");
|
||||
|
||||
run(1000, 2000);
|
||||
expect(this.out.getOutput()).toContain("1 seconds");
|
||||
|
||||
run(1000, 1100);
|
||||
expect(this.out.getOutput()).toContain("0.1 seconds");
|
||||
repeatedlyInvoke(function(){self.reporter.reportSpecResults(failingSpec);}, 49);
|
||||
|
||||
run(1000, 1010);
|
||||
expect(this.out.getOutput()).toContain("0.01 seconds");
|
||||
expect(this.out.getOutput()).
|
||||
toEqual(repeat(red("F"), 49).join(""));
|
||||
|
||||
run(1000, 1001);
|
||||
expect(this.out.getOutput()).toContain("0.001 seconds");
|
||||
});
|
||||
repeatedlyInvoke(function(){self.reporter.reportSpecResults(failingSpec);}, 3);
|
||||
|
||||
it("prints the full finished message", function(){
|
||||
this.reporter.now = function(){return 1000;};
|
||||
this.reporter.reportRunnerStarting();
|
||||
this.reporter.now = function(){return 1777;};
|
||||
this.reporter.reportRunnerResults(failingRun);
|
||||
expect(this.out.getOutput()).toContain("Finished in 0.777 seconds");
|
||||
expect(this.out.getOutput()).
|
||||
toEqual(fiftyRedFs + newline +
|
||||
red("F") + red("F"));
|
||||
|
||||
repeatedlyInvoke(function(){self.reporter.reportSpecResults(failingSpec);}, 48);
|
||||
repeatedlyInvoke(function(){self.reporter.reportSpecResults(passingSpec);}, 2);
|
||||
|
||||
expect(this.out.getOutput()).
|
||||
toEqual(fiftyRedFs + newline +
|
||||
fiftyRedFs + newline +
|
||||
green(".") + green("."));
|
||||
});
|
||||
});
|
||||
|
||||
describe("specs/expectations/failures summary", function(){
|
||||
it("prints statistics in green if there were no failures", function() {
|
||||
this.reporter.reportRunnerResults({
|
||||
results:function(){return {items_: [null, null, null], totalCount: 7, failedCount: 0};}
|
||||
});
|
||||
expect(this.out.getOutput()).
|
||||
toContain("3 specs, 7 expectations, 0 failures");
|
||||
describe('A suite runs', function(){
|
||||
it("remembers suite results", function(){
|
||||
var emptyResults = function(){return {items_:[]};};
|
||||
this.reporter.reportSuiteResults({description:"Oven", results:emptyResults});
|
||||
this.reporter.reportSuiteResults({description:"Mixer", results:emptyResults});
|
||||
|
||||
var self = this;
|
||||
var descriptions = [];
|
||||
for(var i=0; i<self.reporter.suiteResults.length; i++)
|
||||
descriptions.push(self.reporter.suiteResults[i].description);
|
||||
|
||||
expect(descriptions).toEqual(["Oven", "Mixer"]);
|
||||
});
|
||||
|
||||
it("prints statistics in red if there was a failure", function() {
|
||||
this.reporter.reportRunnerResults({
|
||||
results:function(){return {items_: [null, null, null], totalCount: 7, failedCount: 3};}
|
||||
});
|
||||
expect(this.out.getOutput()).
|
||||
toContain("3 specs, 7 expectations, 3 failures");
|
||||
it("creates a description out of the current suite and any parent suites", function(){
|
||||
var emptyResults = function(){return {items_:[]};};
|
||||
var grandparentSuite = {description:"My house", results:emptyResults};
|
||||
var parentSuite = {description:"kitchen", parentSuite: grandparentSuite, results:emptyResults};
|
||||
this.reporter.reportSuiteResults({description:"oven", parentSuite: parentSuite, results:emptyResults});
|
||||
|
||||
expect(this.reporter.suiteResults[0].description).toEqual("My house kitchen oven");
|
||||
});
|
||||
|
||||
it("handles pluralization with 1's ones appropriately", function() {
|
||||
this.reporter.reportRunnerResults({
|
||||
results:function(){return {items_: [null], totalCount: 1, failedCount: 1};}
|
||||
});
|
||||
expect(this.out.getOutput()).
|
||||
toContain("1 spec, 1 expectation, 1 failure");
|
||||
it("gathers failing spec results from the suite. the spec must have a description.", function(){
|
||||
this.reporter.reportSuiteResults({description:"Oven",
|
||||
results:function(){
|
||||
return {
|
||||
items_:[
|
||||
{failedCount:0, description:"specOne"},
|
||||
{failedCount:99, description:"specTwo"},
|
||||
{failedCount:0, description:"specThree"},
|
||||
{failedCount:88, description:"specFour"},
|
||||
{failedCount:3}
|
||||
]
|
||||
};
|
||||
}});
|
||||
|
||||
expect(this.reporter.suiteResults[0].failedSpecResults).
|
||||
toEqual([
|
||||
{failedCount:99, description:"specTwo"},
|
||||
{failedCount:88, description:"specFour"}
|
||||
]);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe("done callback", function(){
|
||||
it("calls back when done", function() {
|
||||
expect(this.done).toBeFalsy();
|
||||
this.reporter.reportRunnerResults({
|
||||
results:function(){return {items_: [null, null, null], totalCount: 7, failedCount: 0};}
|
||||
|
||||
describe('Finishes', function(){
|
||||
|
||||
describe('Spec failure information', function(){
|
||||
|
||||
it("prints suite and spec descriptions together as a sentence", function(){
|
||||
this.reporter.suiteResults = [
|
||||
{description:"The oven", failedSpecResults:[
|
||||
{description:"heats up", items_:[]},
|
||||
{description:"cleans itself", items_:[]}
|
||||
]},
|
||||
{description:"The mixer", failedSpecResults:[
|
||||
{description:"blends things together", items_:[]}
|
||||
]}
|
||||
];
|
||||
|
||||
this.reporter.reportRunnerResults(failingRun);
|
||||
|
||||
expect(this.out.getOutput()).toContain("The oven heats up");
|
||||
expect(this.out.getOutput()).toContain("The oven cleans itself");
|
||||
expect(this.out.getOutput()).toContain("The mixer blends things together");
|
||||
});
|
||||
expect(this.done).toBeTruthy();
|
||||
});
|
||||
|
||||
it("prints stack trace of spec failure", function(){
|
||||
this.reporter.suiteResults = [
|
||||
{description:"The oven", failedSpecResults:[
|
||||
{description:"heats up",
|
||||
items_:[
|
||||
{trace:{stack:"stack trace one"}},
|
||||
{trace:{stack:"stack trace two"}}
|
||||
]}
|
||||
]}
|
||||
];
|
||||
|
||||
this.reporter.reportRunnerResults(failingRun);
|
||||
|
||||
expect(this.out.getOutput()).toContain("The oven heats up");
|
||||
expect(this.out.getOutput()).toContain("stack trace one");
|
||||
expect(this.out.getOutput()).toContain("stack trace two");
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('Finished line', function(){
|
||||
|
||||
it("prints the elapsed time in the summary message", function(){
|
||||
this.reporter.now = function(){return 1000;};
|
||||
this.reporter.reportRunnerStarting();
|
||||
this.reporter.now = function(){return 1777;};
|
||||
this.reporter.reportRunnerResults(passingRun);
|
||||
expect(this.out.getOutput()).toContain("0.777 seconds");
|
||||
});
|
||||
|
||||
it("prints round time numbers correctly", function(){
|
||||
var self = this;
|
||||
function run(startTime, endTime) {
|
||||
self.out.clear();
|
||||
self.reporter.runnerStartTime = startTime;
|
||||
self.reporter.now = function(){return endTime;};
|
||||
self.reporter.reportRunnerResults(passingRun);
|
||||
}
|
||||
|
||||
run(1000, 11000);
|
||||
expect(this.out.getOutput()).toContain("10 seconds");
|
||||
|
||||
run(1000, 2000);
|
||||
expect(this.out.getOutput()).toContain("1 seconds");
|
||||
|
||||
run(1000, 1100);
|
||||
expect(this.out.getOutput()).toContain("0.1 seconds");
|
||||
|
||||
run(1000, 1010);
|
||||
expect(this.out.getOutput()).toContain("0.01 seconds");
|
||||
|
||||
run(1000, 1001);
|
||||
expect(this.out.getOutput()).toContain("0.001 seconds");
|
||||
});
|
||||
|
||||
it("prints the full finished message", function(){
|
||||
this.reporter.now = function(){return 1000;};
|
||||
this.reporter.reportRunnerStarting();
|
||||
this.reporter.now = function(){return 1777;};
|
||||
this.reporter.reportRunnerResults(failingRun);
|
||||
expect(this.out.getOutput()).toContain("Finished in 0.777 seconds");
|
||||
});
|
||||
});
|
||||
|
||||
describe("specs/expectations/failures summary", function(){
|
||||
it("prints statistics in green if there were no failures", function() {
|
||||
this.reporter.reportRunnerResults({
|
||||
results:function(){return {items_: [null, null, null], totalCount: 7, failedCount: 0};}
|
||||
});
|
||||
expect(this.out.getOutput()).
|
||||
toContain("3 specs, 7 expectations, 0 failures");
|
||||
});
|
||||
|
||||
it("prints statistics in red if there was a failure", function() {
|
||||
this.reporter.reportRunnerResults({
|
||||
results:function(){return {items_: [null, null, null], totalCount: 7, failedCount: 3};}
|
||||
});
|
||||
expect(this.out.getOutput()).
|
||||
toContain("3 specs, 7 expectations, 3 failures");
|
||||
});
|
||||
|
||||
it("handles pluralization with 1's ones appropriately", function() {
|
||||
this.reporter.reportRunnerResults({
|
||||
results:function(){return {items_: [null], totalCount: 1, failedCount: 1};}
|
||||
});
|
||||
expect(this.out.getOutput()).
|
||||
toContain("1 spec, 1 expectation, 1 failure");
|
||||
});
|
||||
});
|
||||
|
||||
describe("done callback", function(){
|
||||
it("calls back when done", function() {
|
||||
expect(this.done).toBeFalsy();
|
||||
this.reporter.reportRunnerResults({
|
||||
results:function(){return {items_: [null, null, null], totalCount: 7, failedCount: 0};}
|
||||
});
|
||||
expect(this.done).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
|
@ -10,6 +10,37 @@ describe('WaitsForBlock', function () {
|
||||
onComplete = jasmine.createSpy("onComplete");
|
||||
});
|
||||
|
||||
describe("jasmine.VERBOSE", function() {
|
||||
var jasmineVerboseOriginal;
|
||||
beforeEach(function() {
|
||||
jasmineVerboseOriginal = jasmine.VERBOSE;
|
||||
spyOn(env.reporter, 'log');
|
||||
|
||||
});
|
||||
it('do not show information if jasmine.VERBOSE is set to false', function () {
|
||||
jasmine.VERBOSE = false;
|
||||
var latchFunction = function() {
|
||||
return true;
|
||||
};
|
||||
var block = new jasmine.WaitsForBlock(env, timeout, latchFunction, message, spec);
|
||||
expect(env.reporter.log).not.toHaveBeenCalled();
|
||||
block.execute(onComplete);
|
||||
expect(env.reporter.log).not.toHaveBeenCalled();
|
||||
jasmine.VERBOSE = jasmineVerboseOriginal;
|
||||
});
|
||||
it('show information if jasmine.VERBOSE is set to true', function () {
|
||||
jasmine.VERBOSE = true;
|
||||
var latchFunction = function() {
|
||||
return true;
|
||||
};
|
||||
var block = new jasmine.WaitsForBlock(env, timeout, latchFunction, message, spec);
|
||||
expect(env.reporter.log).not.toHaveBeenCalled();
|
||||
block.execute(onComplete);
|
||||
expect(env.reporter.log).toHaveBeenCalled();
|
||||
jasmine.VERBOSE = jasmineVerboseOriginal;
|
||||
});
|
||||
});
|
||||
|
||||
it('onComplete should be called if the latchFunction returns true', function () {
|
||||
var latchFunction = function() {
|
||||
return true;
|
||||
@ -84,4 +115,4 @@ describe('WaitsForBlock', function () {
|
||||
expect(onComplete).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -6,7 +6,9 @@ jasmine.WaitsBlock = function(env, timeout, spec) {
|
||||
jasmine.util.inherit(jasmine.WaitsBlock, jasmine.Block);
|
||||
|
||||
jasmine.WaitsBlock.prototype.execute = function (onComplete) {
|
||||
this.env.reporter.log('>> Jasmine waiting for ' + this.timeout + ' ms...');
|
||||
if (jasmine.VERBOSE) {
|
||||
this.env.reporter.log('>> Jasmine waiting for ' + this.timeout + ' ms...');
|
||||
}
|
||||
this.env.setTimeout(function () {
|
||||
onComplete();
|
||||
}, this.timeout);
|
||||
|
@ -21,7 +21,9 @@ jasmine.util.inherit(jasmine.WaitsForBlock, jasmine.Block);
|
||||
jasmine.WaitsForBlock.TIMEOUT_INCREMENT = 10;
|
||||
|
||||
jasmine.WaitsForBlock.prototype.execute = function(onComplete) {
|
||||
this.env.reporter.log('>> Jasmine waiting for ' + (this.message || 'something to happen'));
|
||||
if (jasmine.VERBOSE) {
|
||||
this.env.reporter.log('>> Jasmine waiting for ' + (this.message || 'something to happen'));
|
||||
}
|
||||
var latchFunctionResult;
|
||||
try {
|
||||
latchFunctionResult = this.latchFunction.apply(this.spec);
|
||||
@ -49,4 +51,4 @@ jasmine.WaitsForBlock.prototype.execute = function(onComplete) {
|
||||
self.execute(onComplete);
|
||||
}, jasmine.WaitsForBlock.TIMEOUT_INCREMENT);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
@ -22,6 +22,12 @@ jasmine.unimplementedMethod_ = function() {
|
||||
*/
|
||||
jasmine.undefined = jasmine.___undefined___;
|
||||
|
||||
/**
|
||||
* Show diagnostic messages in the console if set to true
|
||||
*
|
||||
*/
|
||||
jasmine.VERBOSE = false;
|
||||
|
||||
/**
|
||||
* Default interval in milliseconds for event loop yields (e.g. to allow network activity or to refresh the screen with the HTML-based runner). Small values here may result in slow test running. Zero means no updates until all tests have completed.
|
||||
*
|
||||
@ -599,4 +605,4 @@ jasmine.XmlHttpRequest = (typeof XMLHttpRequest == "undefined") ? function() {
|
||||
if (!xhr) throw new Error("This browser does not support XMLHttpRequest.");
|
||||
|
||||
return xhr;
|
||||
} : XMLHttpRequest;
|
||||
} : XMLHttpRequest;
|
||||
|
@ -1,14 +1,24 @@
|
||||
body {
|
||||
font-family: "Helvetica Neue Light", "Lucida Grande", "Calibri", "Arial", sans-serif;
|
||||
margin: 0;
|
||||
background-color: #f0f0f0;
|
||||
}
|
||||
|
||||
|
||||
.jasmine_reporter a:visited, .jasmine_reporter a {
|
||||
color: #303;
|
||||
a {
|
||||
text-decoration: none;
|
||||
color: #777;
|
||||
}
|
||||
|
||||
.jasmine_reporter a:hover, .jasmine_reporter a:active {
|
||||
color: blue;
|
||||
a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.description {
|
||||
display: block;
|
||||
padding: .4em 0 .4em 1.5em;
|
||||
font-size: .8em;
|
||||
min-height: 1.2em;
|
||||
line-height: 1.2em;
|
||||
}
|
||||
|
||||
.run_spec {
|
||||
@ -16,111 +26,240 @@ body {
|
||||
padding-right: 5px;
|
||||
font-size: .8em;
|
||||
text-decoration: none;
|
||||
display: none;
|
||||
}
|
||||
|
||||
.jasmine_reporter {
|
||||
margin: 0 5px;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.banner {
|
||||
color: #303;
|
||||
background-color: #fef;
|
||||
padding: 5px;
|
||||
padding: 0 1.5em;
|
||||
height: 1.2em;
|
||||
line-height: 1.2em;
|
||||
}
|
||||
|
||||
.logo {
|
||||
float: left;
|
||||
font-size: 1.1em;
|
||||
font-size: .8em;
|
||||
padding-left: 5px;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.logo .version {
|
||||
font-size: .6em;
|
||||
padding-left: 1em;
|
||||
font-size: .8em;
|
||||
padding-left: .5em;
|
||||
color: gray;
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
.runner.running {
|
||||
background-color: yellow;
|
||||
}
|
||||
|
||||
|
||||
.options {
|
||||
text-align: right;
|
||||
font-size: .8em;
|
||||
font-size: .6em;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
.suite {
|
||||
border: 1px outset gray;
|
||||
margin: 5px 0;
|
||||
padding-left: 1em;
|
||||
position: relative;
|
||||
margin: 10px 1.5em;
|
||||
padding-bottom: 3px;
|
||||
-moz-border-radius: 6px;
|
||||
border-radius: 6px;
|
||||
-moz-box-shadow: 0px 1px 4px #200;
|
||||
-webkit-box-shadow: 0px 1px 4px #200;
|
||||
box-shadow: 0px 1px 4px #200;
|
||||
background-color: #ddd;
|
||||
}
|
||||
|
||||
.suite .suite {
|
||||
margin: 5px;
|
||||
-moz-border-radius: 3px;
|
||||
border-radius: 3px;
|
||||
|
||||
}
|
||||
|
||||
.suite > .description {
|
||||
padding-left: 1.2em;
|
||||
|
||||
border-bottom: 1px solid gray;
|
||||
-moz-border-radius-topleft: 6px;
|
||||
-moz-border-radius-topright: 6px;
|
||||
border-top-left-radius: 6px;
|
||||
border-top-right-radius: 6px;
|
||||
|
||||
background-image: -webkit-gradient(
|
||||
linear,
|
||||
left bottom,
|
||||
left top,
|
||||
color-stop(0.1, rgb(186,186,186)),
|
||||
color-stop(0.9, rgb(240,240,240))
|
||||
);
|
||||
background-image: -moz-linear-gradient(
|
||||
center bottom,
|
||||
rgb(186,186,186) 10%,
|
||||
rgb(240,240,240) 90%
|
||||
);
|
||||
}
|
||||
|
||||
.suite .suite>.description {
|
||||
-moz-border-radius-topleft: 3px;
|
||||
-moz-border-radius-topright: 3px;
|
||||
border-top-left-radius: 3px;
|
||||
border-top-right-radius: 3px;
|
||||
}
|
||||
|
||||
.suite.passed {
|
||||
background-color: #dfd;
|
||||
border-color: #bbb;
|
||||
}
|
||||
|
||||
.suite.failed {
|
||||
background-color: #fdd;
|
||||
border-color: #fcc;
|
||||
}
|
||||
|
||||
.suite > .description {
|
||||
font-weight: 700;
|
||||
font-size: 1em;
|
||||
text-shadow: 0px 1px 0px #eee;
|
||||
color: #777;
|
||||
}
|
||||
|
||||
.suite.passed > .description {
|
||||
color: rgb(94,125,0);
|
||||
text-shadow: 0px 1px 0px #ddd;
|
||||
}
|
||||
|
||||
.suite.failed > .description {
|
||||
color: rgb(176,57,17);
|
||||
}
|
||||
|
||||
.spec {
|
||||
margin: 5px;
|
||||
padding-left: 1em;
|
||||
margin: 0;
|
||||
clear: both;
|
||||
position: relative;
|
||||
padding-bottom: 0;
|
||||
border-bottom: 1px solid gray;
|
||||
}
|
||||
|
||||
.spec.failed, .spec.passed, .spec.skipped {
|
||||
padding-bottom: 5px;
|
||||
border: 1px solid gray;
|
||||
|
||||
}
|
||||
|
||||
.spec.failed:first-child, .spec.passed:first-child, .spec.skipped:first-child {
|
||||
}
|
||||
|
||||
.spec.failed {
|
||||
background-color: #fbb;
|
||||
border-color: red;
|
||||
background-color: white;
|
||||
}
|
||||
|
||||
.spec > .description {
|
||||
color: #666;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.spec.failed > .description {
|
||||
color: white;
|
||||
|
||||
background-image: -webkit-gradient(
|
||||
linear,
|
||||
left bottom,
|
||||
left top,
|
||||
color-stop(0.1, rgb(176,57,17)),
|
||||
color-stop(0.94, rgb(237,87,0))
|
||||
);
|
||||
background-image: -moz-linear-gradient(
|
||||
center bottom,
|
||||
rgb(176,57,17) 10%,
|
||||
rgb(237,87,0) 94%
|
||||
);
|
||||
}
|
||||
|
||||
.spec.failed > .description:before {
|
||||
display: block;
|
||||
position: absolute;
|
||||
left: 5px;
|
||||
top: 8px;
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
content: ".";
|
||||
color: transparent;
|
||||
border: 1px solid #ffffff;
|
||||
|
||||
-moz-border-radius: 5px;
|
||||
|
||||
background-image: -webkit-gradient(
|
||||
linear,
|
||||
left bottom,
|
||||
left top,
|
||||
color-stop(0.1, rgb(176,57,17)),
|
||||
color-stop(0.94, rgb(237,87,0))
|
||||
);
|
||||
background-image: -moz-linear-gradient(
|
||||
center bottom,
|
||||
rgb(176,57,17) 10%,
|
||||
rgb(237,87,0) 94%
|
||||
);
|
||||
}
|
||||
|
||||
.spec.passed {
|
||||
background-color: #bfb;
|
||||
border-color: green;
|
||||
background-color: white;
|
||||
border-color: #bbb;
|
||||
}
|
||||
|
||||
.spec.passed>.description {
|
||||
background-color: #ddd;
|
||||
}
|
||||
|
||||
.spec.passed>.description:before {
|
||||
display: block;
|
||||
position: absolute;
|
||||
left: 6px;
|
||||
top: 9px;
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
content: ".";
|
||||
color: transparent;
|
||||
|
||||
-moz-border-radius: 4px;
|
||||
|
||||
background-image: -webkit-gradient(
|
||||
linear,
|
||||
left bottom,
|
||||
left top,
|
||||
color-stop(0.1, rgb(94,125,0)),
|
||||
color-stop(0.9, rgb(167,212,21))
|
||||
);
|
||||
background-image: -moz-linear-gradient(
|
||||
center bottom,
|
||||
rgb(94,125,0) 10%,
|
||||
rgb(167,212,21) 90%
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
.spec.skipped {
|
||||
background-color: #bbb;
|
||||
}
|
||||
|
||||
|
||||
.messages {
|
||||
border-left: 1px dashed gray;
|
||||
padding-left: 1em;
|
||||
padding-right: 1em;
|
||||
font-size: .8em;
|
||||
padding: 5px 1.5em 0 1.5em;
|
||||
line-height: 1.2em;
|
||||
}
|
||||
|
||||
.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;
|
||||
@ -132,14 +271,22 @@ body {
|
||||
}
|
||||
|
||||
.stackTrace {
|
||||
white-space: pre;
|
||||
font-size: .8em;
|
||||
margin-left: 10px;
|
||||
padding: 5px 1em;
|
||||
margin: 5px 0;
|
||||
max-height: 5em;
|
||||
overflow: auto;
|
||||
border: 1px inset red;
|
||||
padding: 1em;
|
||||
overflow: hidden;
|
||||
|
||||
border: 1px solid #baa;
|
||||
background: #eef;
|
||||
|
||||
white-space: pre;
|
||||
font-size: 1.2em;
|
||||
line-height: 1.5em;
|
||||
font-family: monospace;
|
||||
}
|
||||
|
||||
.stackTrace:hover {
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.finished-at {
|
||||
@ -152,15 +299,64 @@ body {
|
||||
display: block;
|
||||
}
|
||||
|
||||
|
||||
#jasmine_content {
|
||||
position:fixed;
|
||||
position: fixed;
|
||||
right: 100%;
|
||||
}
|
||||
|
||||
.runner {
|
||||
border: 1px solid gray;
|
||||
display: block;
|
||||
margin: 5px 0;
|
||||
padding: 2px 0 2px 10px;
|
||||
margin: 5px 0 10px 0;
|
||||
padding: 2px 0 2px 1.5em;
|
||||
|
||||
border-top: 1px solid gray;
|
||||
-moz-box-shadow: 0px 1px 4px #000;
|
||||
-webkit-box-shadow: 0px 1px 4px #000;
|
||||
box-shadow: 0px 1px 4px #000;
|
||||
|
||||
font-size: .8em;
|
||||
}
|
||||
|
||||
.runner.failed {
|
||||
background-image: -webkit-gradient(
|
||||
linear,
|
||||
left bottom,
|
||||
left top,
|
||||
color-stop(0.1, rgb(176,57,17)),
|
||||
color-stop(0.94, rgb(237,87,0))
|
||||
);
|
||||
background-image: -moz-linear-gradient(
|
||||
center bottom,
|
||||
rgb(176,57,17) 10%,
|
||||
rgb(237,87,0) 94%
|
||||
);
|
||||
}
|
||||
|
||||
.runner.passed {
|
||||
|
||||
background-image: -webkit-gradient(
|
||||
linear,
|
||||
left bottom,
|
||||
left top,
|
||||
color-stop(0.1, rgb(94,125,0)),
|
||||
color-stop(0.9, rgb(167,212,21))
|
||||
);
|
||||
background-image: -moz-linear-gradient(
|
||||
center bottom,
|
||||
rgb(94,125,0) 10%,
|
||||
rgb(167,212,21) 90%
|
||||
);
|
||||
}
|
||||
|
||||
.runner .description {
|
||||
padding-left: .8em;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.runner.running {
|
||||
background-color: yellow;
|
||||
}
|
||||
|
||||
.runner>.description {
|
||||
height: 1em;
|
||||
}
|