Merge branch 'master' of git://github.com/pivotal/jasmine
This commit is contained in:
commit
fd37be4dff
@ -61,13 +61,14 @@ module Jasmine
|
||||
end
|
||||
|
||||
class RunAdapter
|
||||
def initialize(spec_files_or_proc, jasmine_files = nil)
|
||||
def initialize(spec_files_or_proc, jasmine_files = nil, stylesheets = [])
|
||||
@spec_files_or_proc = spec_files_or_proc
|
||||
@jasmine_files = jasmine_files || [
|
||||
"/__JASMINE_ROOT__/lib/" + File.basename(Dir.glob("#{Jasmine.root}/lib/jasmine*.js").first),
|
||||
"/__JASMINE_ROOT__/lib/TrivialReporter.js",
|
||||
"/__JASMINE_ROOT__/lib/json2.js"
|
||||
]
|
||||
@stylesheets = ["/__JASMINE_ROOT__/lib/jasmine.css"] + stylesheets
|
||||
end
|
||||
|
||||
def call(env)
|
||||
@ -77,7 +78,7 @@ module Jasmine
|
||||
jasmine_files = @jasmine_files
|
||||
jasmine_files = jasmine_files.call if jasmine_files.respond_to?(:call)
|
||||
|
||||
css_files = ["/__JASMINE_ROOT__/lib/jasmine.css"]
|
||||
css_files = @stylesheets
|
||||
|
||||
body = ERB.new(File.read(File.join(File.dirname(__FILE__), "run.html"))).result(binding)
|
||||
[
|
||||
@ -113,12 +114,12 @@ module Jasmine
|
||||
end
|
||||
|
||||
class SimpleServer
|
||||
def self.start(port, spec_files_or_proc, mappings, jasmine_files = nil)
|
||||
def self.start(port, spec_files_or_proc, mappings, jasmine_files = nil, stylesheets = [])
|
||||
require 'thin'
|
||||
|
||||
config = {
|
||||
'/run.html' => Jasmine::Redirect.new('/'),
|
||||
'/' => Jasmine::RunAdapter.new(spec_files_or_proc, jasmine_files)
|
||||
'/' => Jasmine::RunAdapter.new(spec_files_or_proc, jasmine_files, stylesheets)
|
||||
}
|
||||
mappings.each do |from, to|
|
||||
config[from] = Rack::File.new(to)
|
||||
|
@ -15,7 +15,6 @@
|
||||
var jsApiReporter;
|
||||
(function() {
|
||||
var jasmineEnv = jasmine.getEnv();
|
||||
jasmineEnv.updateInterval = 1000;
|
||||
|
||||
jsApiReporter = new jasmine.JsApiReporter();
|
||||
var trivialReporter = new jasmine.TrivialReporter();
|
||||
|
@ -258,7 +258,7 @@ ul.inheritsList
|
||||
</div>
|
||||
<div class="fineprint" style="clear:both">
|
||||
|
||||
Documentation generated by <a href="http://www.jsdoctoolkit.org/" target="_blankt">JsDoc Toolkit</a> 2.1.0 on Tue Sep 29 2009 22:08:06 GMT-0700 (PDT)
|
||||
Documentation generated by <a href="http://www.jsdoctoolkit.org/" target="_blankt">JsDoc Toolkit</a> 2.1.0 on Tue Oct 13 2009 14:46:34 GMT-0700 (PDT)
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@ -300,7 +300,7 @@ ul.inheritsList
|
||||
</div>
|
||||
<div class="fineprint" style="clear:both">
|
||||
|
||||
Documentation generated by <a href="http://www.jsdoctoolkit.org/" target="_blankt">JsDoc Toolkit</a> 2.1.0 on Tue Sep 29 2009 22:08:06 GMT-0700 (PDT)
|
||||
Documentation generated by <a href="http://www.jsdoctoolkit.org/" target="_blankt">JsDoc Toolkit</a> 2.1.0 on Tue Oct 13 2009 14:46:34 GMT-0700 (PDT)
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@ -908,7 +908,7 @@ A convenience method that allows existing specs to be disabled temporarily durin
|
||||
<!-- ============================== footer ================================= -->
|
||||
<div class="fineprint" style="clear:both">
|
||||
|
||||
Documentation generated by <a href="http://www.jsdoctoolkit.org/" target="_blank">JsDoc Toolkit</a> 2.1.0 on Tue Sep 29 2009 22:08:05 GMT-0700 (PDT)
|
||||
Documentation generated by <a href="http://www.jsdoctoolkit.org/" target="_blank">JsDoc Toolkit</a> 2.1.0 on Tue Oct 13 2009 14:46:33 GMT-0700 (PDT)
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -339,7 +339,7 @@ ul.inheritsList
|
||||
<!-- ============================== footer ================================= -->
|
||||
<div class="fineprint" style="clear:both">
|
||||
|
||||
Documentation generated by <a href="http://www.jsdoctoolkit.org/" target="_blank">JsDoc Toolkit</a> 2.1.0 on Tue Sep 29 2009 22:08:05 GMT-0700 (PDT)
|
||||
Documentation generated by <a href="http://www.jsdoctoolkit.org/" target="_blank">JsDoc Toolkit</a> 2.1.0 on Tue Oct 13 2009 14:46:33 GMT-0700 (PDT)
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -507,7 +507,7 @@ ul.inheritsList
|
||||
<!-- ============================== footer ================================= -->
|
||||
<div class="fineprint" style="clear:both">
|
||||
|
||||
Documentation generated by <a href="http://www.jsdoctoolkit.org/" target="_blank">JsDoc Toolkit</a> 2.1.0 on Tue Sep 29 2009 22:08:05 GMT-0700 (PDT)
|
||||
Documentation generated by <a href="http://www.jsdoctoolkit.org/" target="_blank">JsDoc Toolkit</a> 2.1.0 on Tue Oct 13 2009 14:46:33 GMT-0700 (PDT)
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -316,7 +316,7 @@ ul.inheritsList
|
||||
<!-- ============================== footer ================================= -->
|
||||
<div class="fineprint" style="clear:both">
|
||||
|
||||
Documentation generated by <a href="http://www.jsdoctoolkit.org/" target="_blank">JsDoc Toolkit</a> 2.1.0 on Tue Sep 29 2009 22:08:05 GMT-0700 (PDT)
|
||||
Documentation generated by <a href="http://www.jsdoctoolkit.org/" target="_blank">JsDoc Toolkit</a> 2.1.0 on Tue Oct 13 2009 14:46:33 GMT-0700 (PDT)
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -316,7 +316,7 @@ ul.inheritsList
|
||||
<!-- ============================== footer ================================= -->
|
||||
<div class="fineprint" style="clear:both">
|
||||
|
||||
Documentation generated by <a href="http://www.jsdoctoolkit.org/" target="_blank">JsDoc Toolkit</a> 2.1.0 on Tue Sep 29 2009 22:08:05 GMT-0700 (PDT)
|
||||
Documentation generated by <a href="http://www.jsdoctoolkit.org/" target="_blank">JsDoc Toolkit</a> 2.1.0 on Tue Oct 13 2009 14:46:33 GMT-0700 (PDT)
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -700,7 +700,7 @@ ul.inheritsList
|
||||
<!-- ============================== footer ================================= -->
|
||||
<div class="fineprint" style="clear:both">
|
||||
|
||||
Documentation generated by <a href="http://www.jsdoctoolkit.org/" target="_blank">JsDoc Toolkit</a> 2.1.0 on Tue Sep 29 2009 22:08:05 GMT-0700 (PDT)
|
||||
Documentation generated by <a href="http://www.jsdoctoolkit.org/" target="_blank">JsDoc Toolkit</a> 2.1.0 on Tue Oct 13 2009 14:46:33 GMT-0700 (PDT)
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -316,7 +316,7 @@ ul.inheritsList
|
||||
<!-- ============================== footer ================================= -->
|
||||
<div class="fineprint" style="clear:both">
|
||||
|
||||
Documentation generated by <a href="http://www.jsdoctoolkit.org/" target="_blank">JsDoc Toolkit</a> 2.1.0 on Tue Sep 29 2009 22:08:05 GMT-0700 (PDT)
|
||||
Documentation generated by <a href="http://www.jsdoctoolkit.org/" target="_blank">JsDoc Toolkit</a> 2.1.0 on Tue Oct 13 2009 14:46:33 GMT-0700 (PDT)
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -418,7 +418,7 @@ ul.inheritsList
|
||||
<!-- ============================== footer ================================= -->
|
||||
<div class="fineprint" style="clear:both">
|
||||
|
||||
Documentation generated by <a href="http://www.jsdoctoolkit.org/" target="_blank">JsDoc Toolkit</a> 2.1.0 on Tue Sep 29 2009 22:08:05 GMT-0700 (PDT)
|
||||
Documentation generated by <a href="http://www.jsdoctoolkit.org/" target="_blank">JsDoc Toolkit</a> 2.1.0 on Tue Oct 13 2009 14:46:33 GMT-0700 (PDT)
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -396,7 +396,7 @@ ul.inheritsList
|
||||
<!-- ============================== footer ================================= -->
|
||||
<div class="fineprint" style="clear:both">
|
||||
|
||||
Documentation generated by <a href="http://www.jsdoctoolkit.org/" target="_blank">JsDoc Toolkit</a> 2.1.0 on Tue Sep 29 2009 22:08:05 GMT-0700 (PDT)
|
||||
Documentation generated by <a href="http://www.jsdoctoolkit.org/" target="_blank">JsDoc Toolkit</a> 2.1.0 on Tue Oct 13 2009 14:46:33 GMT-0700 (PDT)
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -845,7 +845,7 @@ expect(foo.bar.callCount).toEqual(0);</pre>
|
||||
<!-- ============================== footer ================================= -->
|
||||
<div class="fineprint" style="clear:both">
|
||||
|
||||
Documentation generated by <a href="http://www.jsdoctoolkit.org/" target="_blank">JsDoc Toolkit</a> 2.1.0 on Tue Sep 29 2009 22:08:06 GMT-0700 (PDT)
|
||||
Documentation generated by <a href="http://www.jsdoctoolkit.org/" target="_blank">JsDoc Toolkit</a> 2.1.0 on Tue Oct 13 2009 14:46:34 GMT-0700 (PDT)
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -436,7 +436,7 @@ ul.inheritsList
|
||||
<!-- ============================== footer ================================= -->
|
||||
<div class="fineprint" style="clear:both">
|
||||
|
||||
Documentation generated by <a href="http://www.jsdoctoolkit.org/" target="_blank">JsDoc Toolkit</a> 2.1.0 on Tue Sep 29 2009 22:08:06 GMT-0700 (PDT)
|
||||
Documentation generated by <a href="http://www.jsdoctoolkit.org/" target="_blank">JsDoc Toolkit</a> 2.1.0 on Tue Oct 13 2009 14:46:34 GMT-0700 (PDT)
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -266,6 +266,29 @@ ul.inheritsList
|
||||
|
||||
|
||||
|
||||
<table class="summaryTable" cellspacing="0" summary="A summary of the fields documented in the class jasmine.">
|
||||
<caption>Field Summary</caption>
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">Field Attributes</th>
|
||||
<th scope="col">Field Name and Description</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
<tr>
|
||||
<td class="attributes"><static> </td>
|
||||
<td class="nameDescription">
|
||||
<div class="fixedFont">
|
||||
jasmine.<b><a href="../symbols/jasmine.html#.UPDATE_INTERVAL">UPDATE_INTERVAL</a></b>
|
||||
</div>
|
||||
<div class="description">Large or small values here may result in slow test running & "Too much recursion" errors</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
|
||||
|
||||
@ -389,6 +412,33 @@ Jasmine environment.</div>
|
||||
|
||||
<!-- ============================== field details ========================== -->
|
||||
|
||||
<div class="sectionTitle">
|
||||
Field Detail
|
||||
</div>
|
||||
|
||||
<a name=".UPDATE_INTERVAL"> </a>
|
||||
<div class="fixedFont"><static>
|
||||
|
||||
|
||||
<span class="light">jasmine.</span><b>UPDATE_INTERVAL</b>
|
||||
|
||||
</div>
|
||||
<div class="description">
|
||||
Large or small values here may result in slow test running & "Too much recursion" errors
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- ============================== method details ========================= -->
|
||||
|
||||
@ -678,7 +728,7 @@ Jasmine environment.
|
||||
<!-- ============================== footer ================================= -->
|
||||
<div class="fineprint" style="clear:both">
|
||||
|
||||
Documentation generated by <a href="http://www.jsdoctoolkit.org/" target="_blank">JsDoc Toolkit</a> 2.1.0 on Tue Sep 29 2009 22:08:05 GMT-0700 (PDT)
|
||||
Documentation generated by <a href="http://www.jsdoctoolkit.org/" target="_blank">JsDoc Toolkit</a> 2.1.0 on Tue Oct 13 2009 14:46:33 GMT-0700 (PDT)
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -316,7 +316,7 @@ ul.inheritsList
|
||||
<!-- ============================== footer ================================= -->
|
||||
<div class="fineprint" style="clear:both">
|
||||
|
||||
Documentation generated by <a href="http://www.jsdoctoolkit.org/" target="_blank">JsDoc Toolkit</a> 2.1.0 on Tue Sep 29 2009 22:08:06 GMT-0700 (PDT)
|
||||
Documentation generated by <a href="http://www.jsdoctoolkit.org/" target="_blank">JsDoc Toolkit</a> 2.1.0 on Tue Oct 13 2009 14:46:34 GMT-0700 (PDT)
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -12,6 +12,12 @@ jasmine.unimplementedMethod_ = function() {
|
||||
throw new Error("unimplemented method");
|
||||
};
|
||||
|
||||
/**
|
||||
* Large or small values here may result in slow test running & "Too much recursion" errors
|
||||
*
|
||||
*/
|
||||
jasmine.UPDATE_INTERVAL = 250;
|
||||
|
||||
/**
|
||||
* Allows for bound functions to be comapred. Internal use only.
|
||||
*
|
||||
@ -183,6 +189,7 @@ jasmine.Spy = function(name) {
|
||||
* mySpy.argsForCall[1] = [7, 8];
|
||||
*/
|
||||
this.argsForCall = [];
|
||||
this.calls = [];
|
||||
};
|
||||
|
||||
/**
|
||||
@ -277,6 +284,7 @@ jasmine.Spy.prototype.reset = function() {
|
||||
this.wasCalled = false;
|
||||
this.callCount = 0;
|
||||
this.argsForCall = [];
|
||||
this.calls = [];
|
||||
this.mostRecentCall = {};
|
||||
};
|
||||
|
||||
@ -286,13 +294,10 @@ jasmine.createSpy = function(name) {
|
||||
spyObj.wasCalled = true;
|
||||
spyObj.callCount++;
|
||||
var args = jasmine.util.argsToArray(arguments);
|
||||
//spyObj.mostRecentCall = {
|
||||
// object: this,
|
||||
// args: args
|
||||
//};
|
||||
spyObj.mostRecentCall.object = this;
|
||||
spyObj.mostRecentCall.args = args;
|
||||
spyObj.argsForCall.push(args);
|
||||
spyObj.calls.push({object: this, args: args});
|
||||
return spyObj.plan.apply(this, arguments);
|
||||
};
|
||||
|
||||
@ -517,7 +522,7 @@ jasmine.version_= {
|
||||
"major": 0,
|
||||
"minor": 9,
|
||||
"build": 0,
|
||||
"revision": 1254287286
|
||||
"revision": 1255470394
|
||||
};
|
||||
/**
|
||||
* @namespace
|
||||
@ -591,9 +596,7 @@ jasmine.Env = function() {
|
||||
|
||||
this.reporter = new jasmine.MultiReporter();
|
||||
|
||||
this.updateInterval = 0;
|
||||
|
||||
this.updateInterval = 0;
|
||||
this.updateInterval = jasmine.UPDATE_INTERVAL
|
||||
this.lastUpdate = 0;
|
||||
this.specFilter = function() {
|
||||
return true;
|
||||
@ -1479,7 +1482,7 @@ jasmine.Queue = function(env) {
|
||||
this.offset = 0;
|
||||
};
|
||||
|
||||
jasmine.Queue.prototype.addBefore = function (block) {
|
||||
jasmine.Queue.prototype.addBefore = function(block) {
|
||||
this.blocks.unshift(block);
|
||||
};
|
||||
|
||||
@ -1487,59 +1490,74 @@ jasmine.Queue.prototype.add = function(block) {
|
||||
this.blocks.push(block);
|
||||
};
|
||||
|
||||
jasmine.Queue.prototype.insertNext = function (block) {
|
||||
jasmine.Queue.prototype.insertNext = function(block) {
|
||||
this.blocks.splice((this.index + this.offset + 1), 0, block);
|
||||
this.offset++;
|
||||
};
|
||||
|
||||
jasmine.Queue.prototype.start = function(onComplete) {
|
||||
var self = this;
|
||||
self.running = true;
|
||||
self.onComplete = onComplete;
|
||||
if (self.blocks[0]) {
|
||||
self.blocks[0].execute(function () {
|
||||
self._next();
|
||||
});
|
||||
} else {
|
||||
self.finish();
|
||||
}
|
||||
this.running = true;
|
||||
this.onComplete = onComplete;
|
||||
this.next_();
|
||||
};
|
||||
|
||||
jasmine.Queue.prototype.isRunning = function () {
|
||||
jasmine.Queue.prototype.isRunning = function() {
|
||||
return this.running;
|
||||
};
|
||||
|
||||
jasmine.Queue.prototype._next = function () {
|
||||
jasmine.Queue.LOOP_DONT_RECURSE = true;
|
||||
|
||||
jasmine.Queue.prototype.next_ = function() {
|
||||
var self = this;
|
||||
var doNext = function () {
|
||||
var goAgain = true;
|
||||
|
||||
while (goAgain) {
|
||||
goAgain = false;
|
||||
|
||||
if (self.index < self.blocks.length) {
|
||||
var calledSynchronously = true;
|
||||
var completedSynchronously = false;
|
||||
|
||||
var onComplete = function () {
|
||||
if (jasmine.Queue.LOOP_DONT_RECURSE && calledSynchronously) {
|
||||
completedSynchronously = true;
|
||||
return;
|
||||
}
|
||||
|
||||
self.offset = 0;
|
||||
self.index++;
|
||||
if (self.index < self.blocks.length) {
|
||||
self.blocks[self.index].execute(function () {
|
||||
self._next();
|
||||
});
|
||||
|
||||
var now = new Date().getTime();
|
||||
if (self.env.updateInterval && now - self.env.lastUpdate > self.env.updateInterval) {
|
||||
self.env.lastUpdate = now;
|
||||
self.env.setTimeout(function() {
|
||||
self.next_();
|
||||
}, 0);
|
||||
} else {
|
||||
self.finish();
|
||||
if (jasmine.Queue.LOOP_DONT_RECURSE && completedSynchronously) {
|
||||
goAgain = true;
|
||||
} else {
|
||||
self.next_();
|
||||
}
|
||||
}
|
||||
};
|
||||
var now = new Date().getTime();
|
||||
if (this.env.updateInterval && now - this.env.lastUpdate > this.env.updateInterval) {
|
||||
this.env.lastUpdate = now;
|
||||
this.env.setTimeout(doNext, 0);
|
||||
self.blocks[self.index].execute(onComplete);
|
||||
|
||||
calledSynchronously = false;
|
||||
if (completedSynchronously) {
|
||||
onComplete();
|
||||
}
|
||||
|
||||
} else {
|
||||
doNext();
|
||||
self.running = false;
|
||||
if (self.onComplete) {
|
||||
self.onComplete();
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
jasmine.Queue.prototype.finish = function () {
|
||||
this.running = false;
|
||||
if (this.onComplete) {
|
||||
this.onComplete();
|
||||
}
|
||||
};
|
||||
|
||||
jasmine.Queue.prototype.results = 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) {
|
||||
|
76
spec/runner.html
Normal file
76
spec/runner.html
Normal file
@ -0,0 +1,76 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Jasmine Test Runner</title>
|
||||
|
||||
<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>
|
||||
<script type="text/javascript" src="../src/Reporter.js"></script>
|
||||
<script type="text/javascript" src="../src/Block.js"></script>
|
||||
|
||||
<script type="text/javascript" src="../src/JsApiReporter.js"></script>
|
||||
<script type="text/javascript" src="../src/Matchers.js"></script>
|
||||
<script type="text/javascript" src="../src/mock-timeout.js"></script>
|
||||
<script type="text/javascript" src="../src/MultiReporter.js"></script>
|
||||
<script type="text/javascript" src="../src/NestedResults.js"></script>
|
||||
<script type="text/javascript" src="../src/PrettyPrinter.js"></script>
|
||||
<script type="text/javascript" src="../src/Queue.js"></script>
|
||||
<script type="text/javascript" src="../src/Reporters.js"></script>
|
||||
<script type="text/javascript" src="../src/Runner.js"></script>
|
||||
<script type="text/javascript" src="../src/Spec.js"></script>
|
||||
<script type="text/javascript" src="../src/Suite.js"></script>
|
||||
<script type="text/javascript" src="../src/version.json"></script>
|
||||
<script type="text/javascript" src="../src/WaitsBlock.js"></script>
|
||||
<script type="text/javascript" src="../src/WaitsForBlock.js"></script>
|
||||
|
||||
<script type="text/javascript" src="../lib/TrivialReporter.js"></script>
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
(function () {
|
||||
var suites = [
|
||||
'suites/SpySpec.js',
|
||||
'suites/JsApiReporterSpec.js',
|
||||
'suites/RunnerSpec.js',
|
||||
'suites/EnvSpec.js',
|
||||
'suites/NestedResultsSpec.js',
|
||||
'suites/ExceptionsSpec.js',
|
||||
'suites/TrivialReporterSpec.js',
|
||||
'suites/MatchersSpec.js',
|
||||
'suites/QueueSpec.js',
|
||||
'suites/ReporterSpec.js',
|
||||
'suites/MultiReporterSpec.js',
|
||||
'suites/PrettyPrintSpec.js',
|
||||
'suites/SpecSpec.js',
|
||||
'suites/SuiteSpec.js',
|
||||
'suites/SpecRunningSpec.js',
|
||||
];
|
||||
for (var i = 0; i < suites.length; i++) {
|
||||
jasmine.include(suites[i], true);
|
||||
}
|
||||
|
||||
var jasmineEnv = jasmine.getEnv();
|
||||
jasmineEnv.updateInterval = 1000;
|
||||
|
||||
var trivialReporter = new jasmine.TrivialReporter();
|
||||
|
||||
jasmineEnv.addReporter(trivialReporter);
|
||||
|
||||
jasmineEnv.specFilter = function(spec) {
|
||||
return trivialReporter.specFilter(spec);
|
||||
};
|
||||
|
||||
window.onload = function() {
|
||||
jasmineEnv.execute();
|
||||
};
|
||||
})();
|
||||
</script>
|
||||
|
||||
<link href="../lib/jasmine.css" rel="stylesheet"/>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
@ -1,10 +1,12 @@
|
||||
describe("jasmine.Env", function() {
|
||||
|
||||
describe('ids', function () {
|
||||
var env;
|
||||
beforeEach(function() {
|
||||
env = new jasmine.Env();
|
||||
env.updateInterval = 0;
|
||||
});
|
||||
|
||||
describe('ids', function () {
|
||||
|
||||
it('nextSpecId should return consecutive integers, starting at 0', function () {
|
||||
expect(env.nextSpecId()).toEqual(0);
|
||||
expect(env.nextSpecId()).toEqual(1);
|
||||
@ -18,11 +20,9 @@ describe("jasmine.Env", function() {
|
||||
});
|
||||
});
|
||||
describe("reporting", function() {
|
||||
var env;
|
||||
var fakeReporter;
|
||||
|
||||
beforeEach(function() {
|
||||
env = new jasmine.Env();
|
||||
fakeReporter = jasmine.createSpyObj("fakeReporter", ["log"]);
|
||||
});
|
||||
|
||||
|
@ -3,6 +3,7 @@ describe('Exceptions:', function() {
|
||||
|
||||
beforeEach(function() {
|
||||
env = new jasmine.Env();
|
||||
env.updateInterval = 0;
|
||||
});
|
||||
|
||||
it('jasmine.formatException formats Firefox exception maessages as expected', function() {
|
||||
|
@ -6,6 +6,7 @@ describe('jasmine.jsApiReporter', function() {
|
||||
|
||||
beforeEach(function() {
|
||||
var env = new jasmine.Env();
|
||||
env.updateInterval = 0;
|
||||
var suite = new jasmine.Suite(env);
|
||||
spec1 = new jasmine.Spec(env, suite, 'spec 1');
|
||||
spec1.runs(function () {
|
||||
|
@ -3,6 +3,7 @@ describe("jasmine.Matchers", function() {
|
||||
|
||||
beforeEach(function() {
|
||||
env = new jasmine.Env();
|
||||
env.updateInterval = 0;
|
||||
});
|
||||
|
||||
function match(value) {
|
||||
|
23
spec/suites/QueueSpec.js
Normal file
23
spec/suites/QueueSpec.js
Normal file
@ -0,0 +1,23 @@
|
||||
describe("jasmine.Queue", function() {
|
||||
it("should not call itself recursively, so we don't get stack overflow errors", function() {
|
||||
var queue = new jasmine.Queue(new jasmine.Env());
|
||||
queue.add(new jasmine.Block(null, function() {}));
|
||||
queue.add(new jasmine.Block(null, function() {}));
|
||||
queue.add(new jasmine.Block(null, function() {}));
|
||||
queue.add(new jasmine.Block(null, function() {}));
|
||||
|
||||
var nestCount = 0;
|
||||
var maxNestCount = 0;
|
||||
var nextCallCount = 0;
|
||||
queue.next_ = function() {
|
||||
nestCount++;
|
||||
if (nestCount > maxNestCount) maxNestCount = nestCount;
|
||||
|
||||
jasmine.Queue.prototype.next_.apply(queue, arguments);
|
||||
nestCount--;
|
||||
};
|
||||
|
||||
queue.start();
|
||||
expect(maxNestCount).toEqual(1);
|
||||
});
|
||||
});
|
@ -4,7 +4,7 @@ describe('jasmine.Reporter', function() {
|
||||
|
||||
beforeEach(function() {
|
||||
env = new jasmine.Env();
|
||||
|
||||
env.updateInterval = 0;
|
||||
});
|
||||
|
||||
it('should get called from the test runner', function() {
|
||||
|
@ -4,6 +4,7 @@ describe('RunnerTest', function() {
|
||||
|
||||
beforeEach(function() {
|
||||
env = new jasmine.Env();
|
||||
env.updateInterval = 0;
|
||||
|
||||
fakeTimer = new jasmine.FakeTimer();
|
||||
env.setTimeout = fakeTimer.setTimeout;
|
||||
|
@ -4,6 +4,7 @@ describe("jasmine spec running", function () {
|
||||
|
||||
beforeEach(function() {
|
||||
env = new jasmine.Env();
|
||||
env.updateInterval = 0;
|
||||
|
||||
fakeTimer = new jasmine.FakeTimer();
|
||||
env.setTimeout = fakeTimer.setTimeout;
|
||||
|
@ -2,6 +2,7 @@ describe('Spec', function () {
|
||||
var env, suite;
|
||||
beforeEach(function() {
|
||||
env = new jasmine.Env();
|
||||
env.updateInterval = 0;
|
||||
suite = new jasmine.Suite(env, 'suite 1');
|
||||
});
|
||||
|
||||
|
@ -4,6 +4,7 @@ describe('Suite', function() {
|
||||
|
||||
beforeEach(function() {
|
||||
env = new jasmine.Env();
|
||||
env.updateInterval = 0;
|
||||
|
||||
fakeTimer = new jasmine.FakeTimer();
|
||||
env.setTimeout = fakeTimer.setTimeout;
|
||||
|
@ -11,9 +11,7 @@ jasmine.Env = function() {
|
||||
|
||||
this.reporter = new jasmine.MultiReporter();
|
||||
|
||||
this.updateInterval = 0;
|
||||
|
||||
this.updateInterval = 0;
|
||||
this.updateInterval = jasmine.UPDATE_INTERVAL
|
||||
this.lastUpdate = 0;
|
||||
this.specFilter = function() {
|
||||
return true;
|
||||
|
81
src/Queue.js
81
src/Queue.js
@ -6,7 +6,7 @@ jasmine.Queue = function(env) {
|
||||
this.offset = 0;
|
||||
};
|
||||
|
||||
jasmine.Queue.prototype.addBefore = function (block) {
|
||||
jasmine.Queue.prototype.addBefore = function(block) {
|
||||
this.blocks.unshift(block);
|
||||
};
|
||||
|
||||
@ -14,59 +14,74 @@ jasmine.Queue.prototype.add = function(block) {
|
||||
this.blocks.push(block);
|
||||
};
|
||||
|
||||
jasmine.Queue.prototype.insertNext = function (block) {
|
||||
jasmine.Queue.prototype.insertNext = function(block) {
|
||||
this.blocks.splice((this.index + this.offset + 1), 0, block);
|
||||
this.offset++;
|
||||
};
|
||||
|
||||
jasmine.Queue.prototype.start = function(onComplete) {
|
||||
var self = this;
|
||||
self.running = true;
|
||||
self.onComplete = onComplete;
|
||||
if (self.blocks[0]) {
|
||||
self.blocks[0].execute(function () {
|
||||
self._next();
|
||||
});
|
||||
} else {
|
||||
self.finish();
|
||||
}
|
||||
this.running = true;
|
||||
this.onComplete = onComplete;
|
||||
this.next_();
|
||||
};
|
||||
|
||||
jasmine.Queue.prototype.isRunning = function () {
|
||||
jasmine.Queue.prototype.isRunning = function() {
|
||||
return this.running;
|
||||
};
|
||||
|
||||
jasmine.Queue.prototype._next = function () {
|
||||
jasmine.Queue.LOOP_DONT_RECURSE = true;
|
||||
|
||||
jasmine.Queue.prototype.next_ = function() {
|
||||
var self = this;
|
||||
var doNext = function () {
|
||||
var goAgain = true;
|
||||
|
||||
while (goAgain) {
|
||||
goAgain = false;
|
||||
|
||||
if (self.index < self.blocks.length) {
|
||||
var calledSynchronously = true;
|
||||
var completedSynchronously = false;
|
||||
|
||||
var onComplete = function () {
|
||||
if (jasmine.Queue.LOOP_DONT_RECURSE && calledSynchronously) {
|
||||
completedSynchronously = true;
|
||||
return;
|
||||
}
|
||||
|
||||
self.offset = 0;
|
||||
self.index++;
|
||||
if (self.index < self.blocks.length) {
|
||||
self.blocks[self.index].execute(function () {
|
||||
self._next();
|
||||
});
|
||||
|
||||
var now = new Date().getTime();
|
||||
if (self.env.updateInterval && now - self.env.lastUpdate > self.env.updateInterval) {
|
||||
self.env.lastUpdate = now;
|
||||
self.env.setTimeout(function() {
|
||||
self.next_();
|
||||
}, 0);
|
||||
} else {
|
||||
self.finish();
|
||||
if (jasmine.Queue.LOOP_DONT_RECURSE && completedSynchronously) {
|
||||
goAgain = true;
|
||||
} else {
|
||||
self.next_();
|
||||
}
|
||||
}
|
||||
};
|
||||
var now = new Date().getTime();
|
||||
if (this.env.updateInterval && now - this.env.lastUpdate > this.env.updateInterval) {
|
||||
this.env.lastUpdate = now;
|
||||
this.env.setTimeout(doNext, 0);
|
||||
self.blocks[self.index].execute(onComplete);
|
||||
|
||||
calledSynchronously = false;
|
||||
if (completedSynchronously) {
|
||||
onComplete();
|
||||
}
|
||||
|
||||
} else {
|
||||
doNext();
|
||||
self.running = false;
|
||||
if (self.onComplete) {
|
||||
self.onComplete();
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
jasmine.Queue.prototype.finish = function () {
|
||||
this.running = false;
|
||||
if (this.onComplete) {
|
||||
this.onComplete();
|
||||
}
|
||||
};
|
||||
|
||||
jasmine.Queue.prototype.results = 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) {
|
||||
|
13
src/base.js
13
src/base.js
@ -12,6 +12,12 @@ jasmine.unimplementedMethod_ = function() {
|
||||
throw new Error("unimplemented method");
|
||||
};
|
||||
|
||||
/**
|
||||
* Large or small values here may result in slow test running & "Too much recursion" errors
|
||||
*
|
||||
*/
|
||||
jasmine.UPDATE_INTERVAL = 250;
|
||||
|
||||
/**
|
||||
* Allows for bound functions to be comapred. Internal use only.
|
||||
*
|
||||
@ -183,6 +189,7 @@ jasmine.Spy = function(name) {
|
||||
* mySpy.argsForCall[1] = [7, 8];
|
||||
*/
|
||||
this.argsForCall = [];
|
||||
this.calls = [];
|
||||
};
|
||||
|
||||
/**
|
||||
@ -277,6 +284,7 @@ jasmine.Spy.prototype.reset = function() {
|
||||
this.wasCalled = false;
|
||||
this.callCount = 0;
|
||||
this.argsForCall = [];
|
||||
this.calls = [];
|
||||
this.mostRecentCall = {};
|
||||
};
|
||||
|
||||
@ -286,13 +294,10 @@ jasmine.createSpy = function(name) {
|
||||
spyObj.wasCalled = true;
|
||||
spyObj.callCount++;
|
||||
var args = jasmine.util.argsToArray(arguments);
|
||||
//spyObj.mostRecentCall = {
|
||||
// object: this,
|
||||
// args: args
|
||||
//};
|
||||
spyObj.mostRecentCall.object = this;
|
||||
spyObj.mostRecentCall.args = args;
|
||||
spyObj.argsForCall.push(args);
|
||||
spyObj.calls.push({object: this, args: args});
|
||||
return spyObj.plan.apply(this, arguments);
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user