aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--jsTestDriver-jquery.conf1
-rw-r--r--jsTestDriver.conf1
-rw-r--r--scenario/Runner.html2
-rw-r--r--scenario/widgets-scenario.js20
-rw-r--r--scenario/widgets-scenarios.old (renamed from scenario/widgets-scenarios.js)0
-rw-r--r--scenario/widgets.html4
-rw-r--r--src/scenario/DSL.js (renamed from scenario/widgets-scenario2.js)32
-rw-r--r--src/scenario/Runner.js15
-rw-r--r--src/scenario/bootstrap.js1
-rw-r--r--test/scenario/RunnerSpec.js18
10 files changed, 67 insertions, 27 deletions
diff --git a/jsTestDriver-jquery.conf b/jsTestDriver-jquery.conf
index 128fcb6c..953e4521 100644
--- a/jsTestDriver-jquery.conf
+++ b/jsTestDriver-jquery.conf
@@ -7,6 +7,7 @@ load:
- test/jquery_alias.js
- src/Angular.js
- src/*.js
+ - src/scenario/Runner.js
- src/scenario/*.js
- test/testabilityPatch.js
- test/angular-mocks.js
diff --git a/jsTestDriver.conf b/jsTestDriver.conf
index 4a702a3e..c28e9ff1 100644
--- a/jsTestDriver.conf
+++ b/jsTestDriver.conf
@@ -7,6 +7,7 @@ load:
- test/jquery_remove.js
- src/Angular.js
- src/*.js
+ - src/scenario/Runner.js
- src/scenario/*.js
- test/testabilityPatch.js
- test/angular-mocks.js
diff --git a/scenario/Runner.html b/scenario/Runner.html
index 5502283a..ffa08af9 100644
--- a/scenario/Runner.html
+++ b/scenario/Runner.html
@@ -2,7 +2,7 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<script type="text/javascript" src="../src/scenario/bootstrap.js"></script>
- <script type="text/javascript" src="widgets-scenario2.js"></script>
+ <script type="text/javascript" src="widgets-scenario.js"></script>
</head>
<body>
</body>
diff --git a/scenario/widgets-scenario.js b/scenario/widgets-scenario.js
new file mode 100644
index 00000000..9e23d4df
--- /dev/null
+++ b/scenario/widgets-scenario.js
@@ -0,0 +1,20 @@
+describe('widgets', function(){
+ it('should verify that basic widgets work', function(){
+ browser.navigateTo('widgets.html');
+
+ expect('{{text.basic}}').toEqual('');
+ input('text.basic').enter('John');
+ expect('{{text.basic}}').toEqual('John');
+
+ expect('{{text.password}}').toEqual('');
+ input('text.password').enter('secret');
+ expect('{{text.password}}').toEqual('secret');
+
+ expect('{{text.hidden}}').toEqual('hiddenValue');
+
+ expect('{{gender}}').toEqual('male');
+ input('gender').select('female');
+ expect('{{gender}}').toEqual('female');
+
+ });
+});
diff --git a/scenario/widgets-scenarios.js b/scenario/widgets-scenarios.old
index a1e6c0ed..a1e6c0ed 100644
--- a/scenario/widgets-scenarios.js
+++ b/scenario/widgets-scenarios.old
diff --git a/scenario/widgets.html b/scenario/widgets.html
index 4d0f30b0..86269e86 100644
--- a/scenario/widgets.html
+++ b/scenario/widgets.html
@@ -26,8 +26,8 @@
</tr>
<tr>
<td>hidden</td>
- <td><input type="hidden" name="hidden" value="hiddenValue" /></td>
- <td>hidden={{hidden}}</td>
+ <td><input type="hidden" name="text.hidden" value="hiddenValue" /></td>
+ <td>text.hidden={{text.hidden}}</td>
</tr>
<tr><th colspan="3">Input selection field</th></tr>
<tr>
diff --git a/scenario/widgets-scenario2.js b/src/scenario/DSL.js
index b966b270..4bc21d6c 100644
--- a/scenario/widgets-scenario2.js
+++ b/src/scenario/DSL.js
@@ -1,4 +1,4 @@
-browser = {
+angular.scenario.dsl.browser = {
navigateTo: function(url){
$scenario.addStep('Navigate to: ' + url, function(done){
var self = this;
@@ -16,21 +16,22 @@ browser = {
}
};
-function input(selector) {
+angular.scenario.dsl.input = function(selector) {
return {
enter: function(value){
- $scenario.addStep("Set input text of '" + selector + "' to value '" + value + "'", function(done){
- var input = this.testDocument.find('input[name=' + selector + ']');
- input.val(value);
- input.trigger('change');
- this.testWindow.angular.element(input[0]).trigger('change');
- done();
+ $scenario.addStep("Set input text of '" + selector + "' to value '" +
+ value + "'", function(done){
+ var input = this.testDocument.find('input[name=' + selector + ']');
+ input.val(value);
+ input.trigger('change');
+ this.testWindow.angular.element(input[0]).trigger('change');
+ done();
});
}
};
-}
+};
-function expect(selector) {
+angular.scenario.dsl.expect = function(selector) {
return {
toEqual: function(expected) {
$scenario.addStep("Expect that " + selector + " equals '" + expected + "'", function(done){
@@ -43,13 +44,4 @@ function expect(selector) {
});
}
};
-}
-
-describe('widgets', function(){
- it('should verify that basic widgets work', function(){
- browser.navigateTo('widgets.html');
- expect('{{text.basic}}').toEqual('');
- input('text.basic').enter('John');
- expect('{{text.basic}}').toEqual('John');
- });
-});
+};
diff --git a/src/scenario/Runner.js b/src/scenario/Runner.js
index 9e20d394..003ce487 100644
--- a/src/scenario/Runner.js
+++ b/src/scenario/Runner.js
@@ -1,9 +1,11 @@
-angular['scenario'] = (angular['scenario'] = {});
+angular['scenario'] = (angular['scenario'] = {});
+angular.scenario['dsl'] = (angular.scenario['dsl'] = {});
angular.scenario.Runner = function(scope, jQuery){
var self = scope.$scenario = this;
this.scope = scope;
this.jQuery = jQuery;
+ angular.extend(scope, angular.scenario.dsl);
var specs = this.specs = {};
var path = [];
@@ -18,7 +20,13 @@ angular.scenario.Runner = function(scope, jQuery){
name: specName,
steps:[]
};
- body();
+ try {
+ body();
+ } catch(err) {
+ self.addStep(err.message || 'ERROR', function(){
+ throw err;
+ });
+ }
self.currentSpec = null;
};
this.logger = function returnNoop(){
@@ -55,6 +63,7 @@ angular.scenario.Runner.prototype = {
return angular.extend(logger(element), {
close: function(){
element.removeClass('running');
+ console.scrollTop(console[0].scrollHeight);
},
fail: function(){
element.removeClass('running');
@@ -66,7 +75,7 @@ angular.scenario.Runner.prototype = {
current = current.parent();
}
}
- });;
+ });
};
}
this.logger = logger(console);
diff --git a/src/scenario/bootstrap.js b/src/scenario/bootstrap.js
index 51d24c38..4c9cdc8d 100644
--- a/src/scenario/bootstrap.js
+++ b/src/scenario/bootstrap.js
@@ -29,6 +29,7 @@
addScript("../../lib/jquery/jquery-1.4.2.js");
addScript("../angular-bootstrap.js");
addScript("Runner.js");
+ addScript("DSL.js");
document.write('<script type="text/javascript">' +
'$scenarioRunner = new angular.scenario.Runner(window, jQuery);' +
'</script>');
diff --git a/test/scenario/RunnerSpec.js b/test/scenario/RunnerSpec.js
index 702e1ab5..35d74f51 100644
--- a/test/scenario/RunnerSpec.js
+++ b/test/scenario/RunnerSpec.js
@@ -37,7 +37,23 @@ describe('Runner', function(){
});
it('should camplain on duplicate it', angular.noop);
-
+ it('should create a failing step if there is a javascript error', function(){
+ var spec;
+ Describe('D1', function(){
+ It('I1', function(){
+ spec = $scenario.currentSpec;
+ throw {message: 'blah'};
+ });
+ });
+ var step = spec.steps[0];
+ expect(step.name).toEqual('blah');
+ try {
+ step.fn();
+ fail();
+ } catch (e) {
+ expect(e.message).toEqual('blah');
+ };
+ });
});
});