aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndres Ornelas Mesta2010-05-24 13:54:32 -0700
committerAndres Ornelas Mesta2010-05-24 13:54:32 -0700
commitf6c67e28c94033edf6a16eb6508de54679cb49db (patch)
tree2789a523583eaf4aa1cb74e03a4a63ff5e046f05
parentd485421e0e5d6c502e4f62de69d1b4b353f20bbd (diff)
downloadangular.js-f6c67e28c94033edf6a16eb6508de54679cb49db.tar.bz2
happy
-rw-r--r--jsTestDriver-jquery.conf3
-rw-r--r--jsTestDriver.conf4
-rw-r--r--scenario/widgets-scenario2.js5
-rw-r--r--scenario/widgets.html1
-rw-r--r--src/scenario/Runner.js44
-rw-r--r--src/scenario/bootstrap.js6
-rw-r--r--test/jquery_alias.js1
-rw-r--r--test/jquery_remove.js1
-rw-r--r--test/scenario/RunnerSpec.js34
9 files changed, 75 insertions, 24 deletions
diff --git a/jsTestDriver-jquery.conf b/jsTestDriver-jquery.conf
index dde88e80..128fcb6c 100644
--- a/jsTestDriver-jquery.conf
+++ b/jsTestDriver-jquery.conf
@@ -4,6 +4,7 @@ load:
- lib/jasmine/jasmine-0.10.3.js
- lib/jasmine-jstd-adapter/JasmineAdapter.js
- lib/jquery/jquery-1.4.2.js
+ - test/jquery_alias.js
- src/Angular.js
- src/*.js
- src/scenario/*.js
@@ -17,3 +18,5 @@ exclude:
- src/angular.suffix
- src/angular-bootstrap.js
- src/AngularPublic.js
+ - test/jquery_remove.js
+
diff --git a/jsTestDriver.conf b/jsTestDriver.conf
index 6f959b8f..4a702a3e 100644
--- a/jsTestDriver.conf
+++ b/jsTestDriver.conf
@@ -3,7 +3,8 @@ server: http://localhost:9876
load:
- lib/jasmine/jasmine-0.10.3.js
- lib/jasmine-jstd-adapter/JasmineAdapter.js
-# - lib/jquery/jquery-1.4.2.js
+ - lib/jquery/jquery-1.4.2.js
+ - test/jquery_remove.js
- src/Angular.js
- src/*.js
- src/scenario/*.js
@@ -13,6 +14,7 @@ load:
- test/*.js
exclude:
+ - test/jquery_alias.js
- src/angular.prefix
- src/angular.suffix
- src/angular-bootstrap.js
diff --git a/scenario/widgets-scenario2.js b/scenario/widgets-scenario2.js
index e24cabad..b966b270 100644
--- a/scenario/widgets-scenario2.js
+++ b/scenario/widgets-scenario2.js
@@ -4,7 +4,7 @@ browser = {
var self = this;
self.testFrame.load(function(){
self.testFrame.unbind();
- self.testDocument = self.testWindow.angular.element(self.testWindow.document);
+ self.testDocument = jQuery(self.testWindow.document);
done();
});
if (this.testFrame.attr('src') == url) {
@@ -23,6 +23,7 @@ function input(selector) {
var input = this.testDocument.find('input[name=' + selector + ']');
input.val(value);
input.trigger('change');
+ this.testWindow.angular.element(input[0]).trigger('change');
done();
});
}
@@ -49,6 +50,6 @@ describe('widgets', function(){
browser.navigateTo('widgets.html');
expect('{{text.basic}}').toEqual('');
input('text.basic').enter('John');
- expect('{{text.basic}}').toEqual('JohnXX');
+ expect('{{text.basic}}').toEqual('John');
});
});
diff --git a/scenario/widgets.html b/scenario/widgets.html
index 5c3afa21..4d0f30b0 100644
--- a/scenario/widgets.html
+++ b/scenario/widgets.html
@@ -2,7 +2,6 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<link rel="stylesheet" type="text/css" href="style.css"/>
- <script type="text/javascript" src="../lib/jquery/jquery-1.4.2.js"></script>
<script type="text/javascript" src="../src/angular-bootstrap.js#autobind"></script>
</head>
<body ng:init="$window.$scope = this">
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(
'<div id="runner">' +
'<div class="console"></div>' +
@@ -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('<script type="text/javascript">$scenarioRunner = new angular.scenario.Runner(window);</script>');
+ document.write('<script type="text/javascript">' +
+ '$scenarioRunner = new angular.scenario.Runner(window, jQuery);' +
+ '</script>');
})(window.onload);
diff --git a/test/jquery_alias.js b/test/jquery_alias.js
new file mode 100644
index 00000000..4b3fad00
--- /dev/null
+++ b/test/jquery_alias.js
@@ -0,0 +1 @@
+var _jQuery = jQuery; \ No newline at end of file
diff --git a/test/jquery_remove.js b/test/jquery_remove.js
new file mode 100644
index 00000000..5283c340
--- /dev/null
+++ b/test/jquery_remove.js
@@ -0,0 +1 @@
+var _jQuery = jQuery.noConflict(true); \ No newline at end of file
diff --git a/test/scenario/RunnerSpec.js b/test/scenario/RunnerSpec.js
index 2883ab7c..702e1ab5 100644
--- a/test/scenario/RunnerSpec.js
+++ b/test/scenario/RunnerSpec.js
@@ -1,14 +1,18 @@
describe('Runner', function(){
- var scenario, runner, log, Describe, It, $scenario;
+ var scenario, runner, log, Describe, It, $scenario, body;
function logger(text) {
- return function(){log += text;};
+ return function(done){
+ log += text;
+ (done||noop)();
+ };
}
beforeEach(function(){
log = '';
scenario = {};
- runner = new angular.scenario.Runner(scenario);
+ body = _jQuery('<div></div>');
+ runner = new angular.scenario.Runner(scenario, _jQuery);
Describe = scenario.describe;
It = scenario.it;
$scenario = scenario.$scenario;
@@ -105,4 +109,28 @@ describe('Runner', function(){
});
});
+ describe('run', function(){
+ var next;
+ it('should execute all specs', function(){
+ Describe('d1', function(){
+ It('it1', function(){ $scenario.addStep('s1', logger('s1,')); });
+ It('it2', function(){
+ $scenario.addStep('s2', logger('s2,'));
+ $scenario.addStep('s2.2', function(done){ next = done; });
+ });
+ });
+ Describe('d2', function(){
+ It('it3', function(){ $scenario.addStep('s3', logger('s3,')); });
+ It('it4', function(){ $scenario.addStep('s4', logger('s4,')); });
+ });
+
+ $scenario.run(body);
+
+ expect(log).toEqual('s1,s2,');
+ next();
+ expect(log).toEqual('s1,s2,s3,s4,');
+
+ });
+ });
+
}); \ No newline at end of file