diff options
| author | Shyam Seshadri | 2010-08-14 00:31:06 +0800 |
|---|---|---|
| committer | Shyam Seshadri | 2010-08-14 01:01:08 +0800 |
| commit | 449d2ef7246b029eb927261526dc1b907ffa3734 (patch) | |
| tree | a90ce25e75776cf162c7c42afea2176d867fcb3b /src | |
| parent | 84b3a1774edb1e12ba0076e32fe8928ba54a48e3 (diff) | |
| download | angular.js-449d2ef7246b029eb927261526dc1b907ffa3734.tar.bz2 | |
Pull in Rajat's changes to add click and url checking dsl
Diffstat (limited to 'src')
| -rw-r--r-- | src/scenario/DSL.js | 50 |
1 files changed, 38 insertions, 12 deletions
diff --git a/src/scenario/DSL.js b/src/scenario/DSL.js index 3b049dc6..ca944014 100644 --- a/src/scenario/DSL.js +++ b/src/scenario/DSL.js @@ -1,5 +1,6 @@ angular.scenario.dsl.browser = { navigateTo: function(url){ + var location = this.location; return $scenario.addFuture('Navigate to: ' + url, function(done){ var self = this; this.testFrame.load(function(){ @@ -15,8 +16,22 @@ angular.scenario.dsl.browser = { this.testFrame[0].contentWindow.location.reload(); } else { this.testFrame.attr('src', url); + location.setLocation(url); } }); + }, + location: { + href: "", + hash: "", + toEqual: function(url) { + return (this.hash == "" ? (url == this.href) : + (url == (this.href + "/#/" + this.hash))); + }, + setLocation: function(url) { + var urlParts = url.split("/#/"); + this.href = urlParts[0] || ""; + this.hash = urlParts[1] || ""; + } } }; @@ -88,17 +103,28 @@ angular.scenario.dsl.repeater = function(selector) { angular.scenario.dsl.element = function(selector) { var nameSuffix = "element '" + selector + "'"; - return $scenario.addFuture('Find ' + nameSuffix, function(done) { - var self = this, repeaterArray = [], ngBindPattern; - var startIndex = selector.search(angular.scenario.dsl.NG_BIND_PATTERN); - if (startIndex >= 0) { - ngBindPattern = selector.substring(startIndex + 2, selector.length - 2); - var element = this.testDocument.find('*').filter(function() { - return self.jQuery(this).attr('ng:bind') == ngBindPattern; - }); - done(element); - } else { - done(this.testDocument.find(selector)); + return { + find: function() { + return $scenario.addFuture('Find ' + nameSuffix, function(done) { + var self = this, repeaterArray = [], ngBindPattern; + var startIndex = selector.search(angular.scenario.dsl.NG_BIND_PATTERN); + if (startIndex >= 0) { + ngBindPattern = selector.substring(startIndex + 2, selector.length - 2); + var element = this.testDocument.find('*').filter(function() { + return self.jQuery(this).attr('ng:bind') == ngBindPattern; + }); + done(element); + } else { + done(this.testDocument.find(selector)); + } + }); + }, + click: function() { + var self = this; + return $scenario.addFuture('Click ' + nameSuffix, function(done) { + _jQuery(self).click(); + done(); + }); } - }); + }; }; |
