diff options
| author | Vojta Jina | 2011-10-24 15:22:34 -0700 | 
|---|---|---|
| committer | Vojta Jina | 2011-10-26 15:58:59 -0700 | 
| commit | dc8ffa51b7ebe5fb9bc1c89087c8b3c9e65d1006 (patch) | |
| tree | 0a42ed953901cd36504942d0c3c74e213e138b60 /src | |
| parent | d7ba5bc83ba9a8937384ea677331c5156ed6772d (diff) | |
| download | angular.js-dc8ffa51b7ebe5fb9bc1c89087c8b3c9e65d1006.tar.bz2 | |
fix(scenario.dsl): Fix dsl for $location
New $location does not have hashSearch, hashPath.
The old dsl was mixing $location / window.location so this solves the problem as well...
Diffstat (limited to 'src')
| -rw-r--r-- | src/markups.js | 4 | ||||
| -rw-r--r-- | src/scenario/dsl.js | 61 | 
2 files changed, 43 insertions, 22 deletions
diff --git a/src/markups.js b/src/markups.js index 75329169..b7761857 100644 --- a/src/markups.js +++ b/src/markups.js @@ -187,7 +187,7 @@ angularTextMarkup('option', function(text, textNode, parentElement){            expect(element('#link-3').attr('href')).toBe("/123");            element('#link-3').click(); -          expect(browser().location().path()).toEqual('/123'); +          expect(browser().window().path()).toEqual('/123');          });          it('should execute ng:click but not reload when href empty string and name specified', function() { @@ -207,7 +207,7 @@ angularTextMarkup('option', function(text, textNode, parentElement){            expect(element('#link-6').attr('href')).toBe("/6");            element('#link-6').click(); -          expect(browser().location().path()).toEqual('/6'); +          expect(browser().window().path()).toEqual('/6');          });        </doc:scenario>      </doc:example> diff --git a/src/scenario/dsl.js b/src/scenario/dsl.js index e0af0c8c..db81dd35 100644 --- a/src/scenario/dsl.js +++ b/src/scenario/dsl.js @@ -34,11 +34,14 @@ angular.scenario.dsl('sleep', function() {   *    browser().navigateTo(url) Loads the url into the frame   *    browser().navigateTo(url, fn) where fn(url) is called and returns the URL to navigate to   *    browser().reload() refresh the page (reload the same URL) - *    browser().location().href() the full URL of the page - *    browser().location().hash() the full hash in the url - *    browser().location().path() the full path in the url - *    browser().location().hashSearch() the hashSearch Object from angular - *    browser().location().hashPath() the hashPath string from angular + *    browser().window.href() window.location.href + *    browser().window.path() window.location.pathname + *    browser().window.search() window.location.search + *    browser().window.hash() window.location.hash without # prefix + *    browser().location().url() see angular.service.$location#url + *    browser().location().path() see angular.service.$location#path + *    browser().location().search() see angular.service.$location#search + *    browser().location().hash() see angular.service.$location#hash   */  angular.scenario.dsl('browser', function() {    var chain = {}; @@ -65,42 +68,60 @@ angular.scenario.dsl('browser', function() {      });    }; -  chain.location = function() { +  chain.window = function() {      var api = {};      api.href = function() { -      return this.addFutureAction('browser url', function($window, $document, done) { +      return this.addFutureAction('window.location.href', function($window, $document, done) {          done(null, $window.location.href);        });      }; +    api.path = function() { +      return this.addFutureAction('window.location.path', function($window, $document, done) { +        done(null, $window.location.pathname); +      }); +    }; + +    api.search = function() { +      return this.addFutureAction('window.location.search', function($window, $document, done) { +        done(null, $window.location.search); +      }); +    }; +      api.hash = function() { -      return this.addFutureAction('browser url hash', function($window, $document, done) { +      return this.addFutureAction('window.location.hash', function($window, $document, done) {          done(null, $window.location.hash.replace('#', ''));        });      }; -    api.path = function() { -      return this.addFutureAction('browser url path', function($window, $document, done) { -        done(null, $window.location.pathname); +    return api; +  }; + +  chain.location = function() { +    var api = {}; + +    api.url = function() { +      return this.addFutureAction('$location.url()', function($window, $document, done) { +        done(null, $window.angular.scope().$service('$location').url());        });      }; -    api.search = function() { -      return this.addFutureAction('browser url search', function($window, $document, done) { -        done(null, $window.angular.scope().$service('$location').search); +    api.path = function() { +      return this.addFutureAction('$location.path()', function($window, $document, done) { +        done(null, $window.angular.scope().$service('$location').path());        });      }; -    api.hashSearch = function() { -      return this.addFutureAction('browser url hash search', function($window, $document, done) { -        done(null, $window.angular.scope().$service('$location').hashSearch); +    api.search = function() { +      return this.addFutureAction('$location.search()', function($window, $document, done) { +        done(null, $window.angular.scope().$service('$location').search());        });      }; -    api.hashPath = function() { -      return this.addFutureAction('browser url hash path', function($window, $document, done) { -        done(null, $window.angular.scope().$service('$location').hashPath); +    api.hash = function() { +      return this.addFutureAction('$location.hash()', function($window, $document, done) { +        done(null, $window.angular.scope().$service('$location').hash());        });      };  | 
