aboutsummaryrefslogtreecommitdiffstats
path: root/src/scenario/DSL.js
diff options
context:
space:
mode:
authorRob Spies2010-06-22 17:09:55 -0700
committerRob Spies2010-06-22 17:09:55 -0700
commit1500e91defa4020bfe9608749b25e585cd1d8e3d (patch)
tree8c2872252b62567dc4eb00f7d7547661d5674c55 /src/scenario/DSL.js
parenteaa397c76b7d28343cde9f3a0338b9b0e79197c8 (diff)
parentb129a1094e6b42ed82c3ccecc2f40daaa0a6cb6a (diff)
downloadangular.js-1500e91defa4020bfe9608749b25e585cd1d8e3d.tar.bz2
Merge http://github.com/angular/angular.js into angular
Conflicts: .gitignore
Diffstat (limited to 'src/scenario/DSL.js')
-rw-r--r--src/scenario/DSL.js63
1 files changed, 63 insertions, 0 deletions
diff --git a/src/scenario/DSL.js b/src/scenario/DSL.js
new file mode 100644
index 00000000..194a28d6
--- /dev/null
+++ b/src/scenario/DSL.js
@@ -0,0 +1,63 @@
+angular.scenario.dsl.browser = {
+ navigateTo: function(url){
+ $scenario.addStep('Navigate to: ' + url, function(done){
+ var self = this;
+ this.testFrame.load(function(){
+ self.testFrame.unbind();
+ 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(done);
+ });
+ if (this.testFrame.attr('src') == url) {
+ this.testFrame[0].contentWindow.location.reload();
+ } else {
+ this.testFrame.attr('src', url);
+ }
+ });
+ }
+};
+
+angular.scenario.dsl.input = function(selector) {
+ return {
+ enter: function(value){
+ $scenario.addStep("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();
+ });
+ },
+ select: function(value){
+ $scenario.addStep("Select radio '" + selector + "' to '" +
+ value + "'", function(done){
+ var input = this.testDocument.
+ find(':radio[name$=@' + selector + '][value=' + value + ']');
+ var event = this.testWindow.document.createEvent('MouseEvent');
+ event.initMouseEvent('click', true, true, this.testWindow, 0,0,0,0,0, false, false, false, false, 0, null);
+ input[0].dispatchEvent(event);
+ done();
+ });
+ }
+ };
+};
+
+angular.scenario.dsl.expect = {
+ repeater: function(selector) {
+ return {
+ count: {
+ toEqual: function(number) {
+ $scenario.addStep("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();
+ });
+ }
+ }
+ };
+ }
+};