diff options
| author | Misko Hevery | 2013-05-02 18:22:03 -0400 | 
|---|---|---|
| committer | Misko Hevery | 2013-05-02 18:22:03 -0400 | 
| commit | a348e90aa141921b914f87ec930cd6ebf481a446 (patch) | |
| tree | e3f7e7be0aecf27840ee7378ff76ef744733943b /test | |
| parent | 4bd7bedf48c0c1ebb62f6bd8c85e8ea00f94502b (diff) | |
| download | angular.js-a348e90aa141921b914f87ec930cd6ebf481a446.tar.bz2 | |
fix($location): compare against actual instead of current URL
Diffstat (limited to 'test')
| -rw-r--r-- | test/ng/locationSpec.js | 64 | 
1 files changed, 63 insertions, 1 deletions
diff --git a/test/ng/locationSpec.js b/test/ng/locationSpec.js index 3588150d..cf7ceaf4 100644 --- a/test/ng/locationSpec.js +++ b/test/ng/locationSpec.js @@ -826,7 +826,15 @@ describe('$location', function() {          initLocation(),          function($browser) {            browserTrigger(link, 'click'); -          expectNoRewrite($browser, 'http://host.com/base/'); +          expectRewriteTo($browser, 'http://host.com/base/'); + +          jqLite(link).attr('href', 'http://host.com/base/foo'); +          browserTrigger(link, 'click'); +          expectRewriteTo($browser, 'http://host.com/base/foo'); + +          jqLite(link).attr('href', 'http://host.com/base/'); +          browserTrigger(link, 'click'); +          expectRewriteTo($browser, 'http://host.com/base/');          }        );      }); @@ -1332,4 +1340,58 @@ describe('$location', function() {        });      });    }); + +  describe('LocationHtml5Url', function() { +    var location, locationIndex; + +    beforeEach(function() { +      location = new LocationHtml5Url('http://server/pre/', 'http://server/pre/path'); +      locationIndex = new LocationHtml5Url('http://server/pre/index.html', 'http://server/pre/path'); +    }); + +    it('should rewrite URL', function() { +      expect(location.$$rewrite('http://other')).toEqual(undefined); +      expect(location.$$rewrite('http://server/pre')).toEqual('http://server/pre/'); +      expect(location.$$rewrite('http://server/pre/')).toEqual('http://server/pre/'); +      expect(location.$$rewrite('http://server/pre/otherPath')).toEqual('http://server/pre/otherPath'); +      expect(locationIndex.$$rewrite('http://server/pre')).toEqual('http://server/pre/'); +      expect(locationIndex.$$rewrite('http://server/pre/')).toEqual('http://server/pre/'); +      expect(locationIndex.$$rewrite('http://server/pre/otherPath')).toEqual('http://server/pre/otherPath'); +    }); +  }); + + +  describe('LocationHashbangUrl', function() { +    var location; + +    beforeEach(function() { +      location = new LocationHashbangUrl('http://server/pre/', 'http://server/pre/#/path'); +    }); + +    it('should rewrite URL', function() { +      expect(location.$$rewrite('http://other')).toEqual(undefined); +      expect(location.$$rewrite('http://server/pre/')).toEqual('http://server/pre/'); +      expect(location.$$rewrite('http://server/pre/#otherPath')).toEqual('http://server/pre/#otherPath'); +    }); +  }); + + +  describe('LocationHashbangInHtml5Url', function() { +    var location, locationIndex; + +    beforeEach(function() { +      location = new LocationHashbangInHtml5Url('http://server/pre/', '#!'); +      locationIndex = new LocationHashbangInHtml5Url('http://server/pre/index.html', '#!'); +    }); + +    it('should rewrite URL', function() { +      expect(location.$$rewrite('http://other')).toEqual(undefined); +      expect(location.$$rewrite('http://server/pre')).toEqual('http://server/pre/'); +      expect(location.$$rewrite('http://server/pre/')).toEqual('http://server/pre/'); +      expect(location.$$rewrite('http://server/pre/otherPath')).toEqual('http://server/pre/#!otherPath'); +      expect(locationIndex.$$rewrite('http://server/pre')).toEqual('http://server/pre/'); +      expect(locationIndex.$$rewrite('http://server/pre/')).toEqual(undefined); +      expect(locationIndex.$$rewrite('http://server/pre/otherPath')).toEqual('http://server/pre/index.html#!otherPath'); +    }); +  });  });  | 
