diff options
| author | Elliott Sprehn | 2010-10-29 16:02:57 -0700 | 
|---|---|---|
| committer | Elliott Sprehn | 2010-11-01 15:21:37 -0700 | 
| commit | 6bb2cd6ee2a35768ac4422395596daf1438e62ff (patch) | |
| tree | 86c52c03c886116176b8df9afa482fb886538963 /test/scenario/dslSpec.js | |
| parent | 2d61040fb085f5d3a226d39726e105c1e6bd7006 (diff) | |
| download | angular.js-6bb2cd6ee2a35768ac4422395596daf1438e62ff.tar.bz2 | |
Provide browser DSL with location() to expect the iframe URL parts. Also move navigateTo() under the browser DSL.
Diffstat (limited to 'test/scenario/dslSpec.js')
| -rw-r--r-- | test/scenario/dslSpec.js | 84 | 
1 files changed, 68 insertions, 16 deletions
| diff --git a/test/scenario/dslSpec.js b/test/scenario/dslSpec.js index ecb5d3e7..cc002612 100644 --- a/test/scenario/dslSpec.js +++ b/test/scenario/dslSpec.js @@ -87,26 +87,78 @@ describe("angular.scenario.dsl", function() {      });    }); -  describe('NavigateTo', function() { -    it('should allow a string url', function() { -      $root.dsl.navigateTo('http://myurl'); -      expect($window.location).toEqual('http://myurl'); -      expect($root.futureResult).toEqual('http://myurl'); -    }); +  describe('Browser', function() { +    describe('NavigateTo', function() { +      it('should allow a string url', function() { +        $root.dsl.browser().navigateTo('http://myurl'); +        expect($window.location).toEqual('http://myurl'); +        expect($root.futureResult).toEqual('http://myurl'); +      }); + +      it('should allow a future url', function() { +        $root.dsl.browser().navigateTo('http://myurl', function() { +          return 'http://futureUrl/'; +        }); +        expect($window.location).toEqual('http://futureUrl/'); +        expect($root.futureResult).toEqual('http://futureUrl/'); +      }); -    it('should allow a future url', function() { -      $root.dsl.navigateTo('http://myurl', function() { -        return 'http://futureUrl/'; +      it('should complete if angular is missing from app frame', function() { +        delete $window.angular; +        $root.dsl.browser().navigateTo('http://myurl'); +        expect($window.location).toEqual('http://myurl'); +        expect($root.futureResult).toEqual('http://myurl');        }); -      expect($window.location).toEqual('http://futureUrl/'); -      expect($root.futureResult).toEqual('http://futureUrl/');      }); -    it('should complete if angular is missing from app frame', function() { -      delete $window.angular; -      $root.dsl.navigateTo('http://myurl'); -      expect($window.location).toEqual('http://myurl'); -      expect($root.futureResult).toEqual('http://myurl'); +    describe('Location', function() { +      beforeEach(function() { +        $window.location = { +          href: 'http://myurl/some/path?foo=10#/bar?x=2', +          pathname: '/some/path', +          search: '?foo=10', +          hash: '#bar?x=2' +        }; +        $window.angular.scope = function() { +          return { +            $location: { +              hashSearch: {x: 2}, +              hashPath: '/bar', +              search: {foo: 10} +            } +          }; +        }; +      }); + +      it('should return full URL for href', function() { +        $root.dsl.browser().location().href(); +        expect($root.futureResult).toEqual($window.location.href); +      }); + +      it('should return the pathname', function() { +        $root.dsl.browser().location().path(); +        expect($root.futureResult).toEqual($window.location.pathname); +      }); + +      it('should return the hash without the #', function() { +        $root.dsl.browser().location().hash(); +        expect($root.futureResult).toEqual('bar?x=2'); +      }); + +      it('should return the query string as an object', function() { +        $root.dsl.browser().location().search(); +        expect($root.futureResult).toEqual({foo: 10}); +      }); + +      it('should return the hashSearch as an object', function() { +        $root.dsl.browser().location().hashSearch(); +        expect($root.futureResult).toEqual({x: 2}); +      }); + +      it('should return the hashPath', function() { +        $root.dsl.browser().location().hashPath(); +        expect($root.futureResult).toEqual('/bar'); +      });      });    }); | 
