From f6c67e28c94033edf6a16eb6508de54679cb49db Mon Sep 17 00:00:00 2001
From: Andres Ornelas Mesta
Date: Mon, 24 May 2010 13:54:32 -0700
Subject: happy
---
src/scenario/Runner.js | 44 +++++++++++++++++++++++++++++---------------
src/scenario/bootstrap.js | 6 ++++--
2 files changed, 33 insertions(+), 17 deletions(-)
(limited to 'src')
diff --git a/src/scenario/Runner.js b/src/scenario/Runner.js
index 970d0c66..9e20d394 100644
--- a/src/scenario/Runner.js
+++ b/src/scenario/Runner.js
@@ -1,8 +1,9 @@
angular['scenario'] = (angular['scenario'] = {});
-angular.scenario.Runner = function(scope){
+angular.scenario.Runner = function(scope, jQuery){
var self = scope.$scenario = this;
this.scope = scope;
+ this.jQuery = jQuery;
var specs = this.specs = {};
var path = [];
@@ -27,6 +28,7 @@ angular.scenario.Runner = function(scope){
angular.scenario.Runner.prototype = {
run: function(body){
+ var jQuery = this.jQuery;
body.append(
'
' +
'
' +
@@ -68,7 +70,19 @@ angular.scenario.Runner.prototype = {
};
}
this.logger = logger(console);
- this.execute("widgets: it should verify that basic widgets work");
+ var specNames = [];
+ angular.foreach(this.specs, function(spec, name){
+ specNames.push(name);
+ }, this);
+ specNames.sort();
+ var self = this;
+ function callback(){
+ var next = specNames.shift();
+ if(next) {
+ self.execute(next, callback);
+ }
+ };
+ callback();
},
addStep: function(name, step) {
@@ -102,21 +116,21 @@ angular.scenario.Runner.prototype = {
}
function next(){
var step = spec.steps[spec.nextStepIndex];
- (result.log || {close:angular.noop}).close();
- result.log = null;
- if (step) {
- spec.nextStepIndex ++;
- result.log = stepLogger('step', step.name);
- try {
- step.fn.call(specThis, next);
- } catch (e) {
- result.fail(e);
- done();
- }
- } else {
- result.passed = !result.failed;
+ (result.log || {close:angular.noop}).close();
+ result.log = null;
+ if (step) {
+ spec.nextStepIndex ++;
+ result.log = stepLogger('step', step.name);
+ try {
+ step.fn.call(specThis, next);
+ } catch (e) {
+ result.fail(e);
done();
}
+ } else {
+ result.passed = !result.failed;
+ done();
+ }
};
next();
return specThis;
diff --git a/src/scenario/bootstrap.js b/src/scenario/bootstrap.js
index 81272bdd..51d24c38 100644
--- a/src/scenario/bootstrap.js
+++ b/src/scenario/bootstrap.js
@@ -20,7 +20,7 @@
window.onload = function(){
_.defer(function(){
- $scenarioRunner.run(jQuery(document.body));
+ $scenarioRunner.run(jQuery(window.document.body));
});
(onLoadDelegate||function(){})();
};
@@ -29,6 +29,8 @@
addScript("../../lib/jquery/jquery-1.4.2.js");
addScript("../angular-bootstrap.js");
addScript("Runner.js");
- document.write('');
+ document.write('');
})(window.onload);
--
cgit v1.2.3