diff options
| author | Vojta Jina | 2011-07-19 15:52:27 +0200 |
|---|---|---|
| committer | Vojta Jina | 2011-09-08 20:37:28 +0200 |
| commit | 91ccb4ba6e203f1b80a1aa7187d8773434948fc2 (patch) | |
| tree | 2ae5b853a818ec67a081e86177e9669706010cf7 /test | |
| parent | d0f459c56fdb3dae692c359a2915acb2fd063c79 (diff) | |
| download | angular.js-91ccb4ba6e203f1b80a1aa7187d8773434948fc2.tar.bz2 | |
feat($browser): add $browser.baseHref()
This method abstracts <base href="" /> in document.head - returns the value.
If absolute href set, it converts the href to relative.
Diffstat (limited to 'test')
| -rw-r--r-- | test/BrowserSpecs.js | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/test/BrowserSpecs.js b/test/BrowserSpecs.js index f92a21af..de4354a0 100644 --- a/test/BrowserSpecs.js +++ b/test/BrowserSpecs.js @@ -691,4 +691,40 @@ describe('browser', function(){ expect(script).toBe(scripts[0]); }); }); + + describe('baseHref', function() { + var jqDocHead; + + function setDocumentBaseHrefTo(href) { + clearDocumentBaseHref(); + jqDocHead.append('<base href="' + href +'" />'); + } + + function clearDocumentBaseHref() { + jqDocHead.find('base').remove(); + } + + beforeEach(function() { + jqDocHead = jqLite(document).find('head'); + }); + + afterEach(clearDocumentBaseHref); + + it('should return value from <base href>', function() { + setDocumentBaseHrefTo('/base/path/'); + expect(browser.baseHref()).toEqual('/base/path/'); + }); + + it('should return undefined if no <base href>', function() { + expect(browser.baseHref()).toBeUndefined(); + }); + + it('should remove domain from <base href>', function() { + setDocumentBaseHrefTo('http://host.com/base/path/'); + expect(browser.baseHref()).toEqual('/base/path/'); + + setDocumentBaseHrefTo('http://host.com/base/path/index.html'); + expect(browser.baseHref()).toEqual('/base/path/index.html'); + }); + }); }); |
