aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/scenario/DSL.js53
-rw-r--r--src/scenario/Future.js29
-rw-r--r--src/scenario/Matcher.js21
-rw-r--r--src/scenario/Runner.js3
4 files changed, 51 insertions, 55 deletions
diff --git a/src/scenario/DSL.js b/src/scenario/DSL.js
index fcadd3ca..ef2f5553 100644
--- a/src/scenario/DSL.js
+++ b/src/scenario/DSL.js
@@ -7,7 +7,8 @@ angular.scenario.dsl.browser = {
self.testWindow = self.testFrame[0].contentWindow;
self.testDocument = jQuery(self.testWindow.document);
self.$browser = self.testWindow.angular.service.$browser();
- self.notifyWhenNoOutstandingRequests = bind(self.$browser, self.$browser.notifyWhenNoOutstandingRequests);
+ self.notifyWhenNoOutstandingRequests =
+ bind(self.$browser, self.$browser.notifyWhenNoOutstandingRequests);
self.notifyWhenNoOutstandingRequests(done);
});
if (this.testFrame.attr('src') == url) {
@@ -19,20 +20,23 @@ angular.scenario.dsl.browser = {
}
};
+function future(name, behavior) {
+ return new Future(name, behavior);
+};
+
angular.scenario.dsl.input = function(selector) {
+ var namePrefix = "input '" + selector + "'";
return {
- enter: function(value){
- $scenario.addFuture("Set input text of '" + selector + "' to '" +
- value + "'", function(done){
- var input = this.testDocument.find('input[name=' + selector + ']');
- input.val(value);
- this.testWindow.angular.element(input[0]).trigger('change');
- done();
+ enter: function(value) {
+ return future(namePrefix + " enter '" + value + "'", function(done) {
+ var input = this.testDocument.find('input[name=' + selector + ']');
+ input.val(value);
+ this.testWindow.angular.element(input[0]).trigger('change');
+ done();
});
},
- select: function(value){
- $scenario.addFuture("Select radio '" + selector + "' to '" +
- value + "'", function(done){
+ select: function(value) {
+ return future(namePrefix + " select '" + value + "'", function(done) {
var input = this.testDocument.
find(':radio[name$=@' + selector + '][value=' + value + ']');
jqLiteWrap(input[0]).trigger('click');
@@ -41,22 +45,15 @@ angular.scenario.dsl.input = function(selector) {
});
}
};
-};
+},
-angular.scenario.dsl.expect = {
- repeater: function(selector) {
- return {
- count: {
- toEqual: function(number) {
- $scenario.addFuture("Expect that there are " + number + " items in Repeater with selector '" + selector + "'", function(done) {
- var items = this.testDocument.find(selector);
- if (items.length != number) {
- this.result.fail("Expected " + number + " but was " + items.length);
- }
- done();
- });
- }
- }
- };
- }
+angular.scenario.dsl.repeater = function(selector) {
+ var namePrefix = "repeater '" + selector + "'";
+ return {
+ count: function() {
+ return future(namePrefix + ' count', function(done) {
+ done(this.testDocument.find(selector).size());
+ });
+ }
+ };
};
diff --git a/src/scenario/Future.js b/src/scenario/Future.js
index c718bba2..6c90df9d 100644
--- a/src/scenario/Future.js
+++ b/src/scenario/Future.js
@@ -6,11 +6,12 @@ function Future(name, behavior) {
}
Future.prototype = {
- fulfill: function(value){
+ fulfill: function(value) {
this.fulfilled = true;
this.value = value;
}
};
+
function Matcher(future, logger) {
var self = this;
this.logger = logger;
@@ -32,29 +33,3 @@ Matcher.addMatcher = function(name, matcher){
};
Matcher.addMatcher('toEqual', function(a,b){ return a == b; });
-
-/*
-
-function future(name, behavior) {
- return new Future(name, behavior);
-};
-
-function repeater(selector) {
- var repeaterFuture = future('repeater ' + selector, function(done) {
- done($(selector));
- });
-
- repeaterFuture.count = function(){
- return future(repeaterFuture.name + ' count', function(done) {
- done(repeaterFuture.value.size());
- });
- };
-
- return repeaterFuture;
-}
-
-function expectX(future) {
- return new Matcher(future, window.alert);
-}
-
- */ \ No newline at end of file
diff --git a/src/scenario/Matcher.js b/src/scenario/Matcher.js
new file mode 100644
index 00000000..dd7b7ee6
--- /dev/null
+++ b/src/scenario/Matcher.js
@@ -0,0 +1,21 @@
+//function Matcher(future, logger) {
+// var self = this;
+// this.logger = logger;
+// this.future = future;
+//}
+//
+//Matcher.addMatcher = function(name, matcher){
+// Matcher.prototype[name] = function(expected) {
+// var future = this.future;
+// $scenario.addFuture(
+// 'expect ' + future.name + ' ' + name + ' ' + expected,
+// function(done){
+// if (matcher(future.value, expected))
+// throw "Expected " + expected + ' but was ' + future.value;
+// done();
+// }
+// );
+// };
+//};
+//
+//Matcher.addMatcher('toEqual', function(a,b){ return a == b; });
diff --git a/src/scenario/Runner.js b/src/scenario/Runner.js
index c77239cc..3fc1c614 100644
--- a/src/scenario/Runner.js
+++ b/src/scenario/Runner.js
@@ -22,6 +22,9 @@ angular.scenario.Runner = function(scope, jQuery){
this.scope.afterEach = function(body) {
afterEach = body;
};
+// this.scope.expect = function(future) {
+// return new Matcher(future, self.logger);
+// };
this.scope.it = function(name, body) {
var specName = path.join(' ') + ': it ' + name;
self.currentSpec = specs[specName] = {