diff options
Diffstat (limited to 'test/ng')
| -rw-r--r-- | test/ng/httpBackendSpec.js | 16 | ||||
| -rw-r--r-- | test/ng/locationSpec.js | 65 | ||||
| -rw-r--r-- | test/ng/urlUtilsSpec.js | 24 |
3 files changed, 15 insertions, 90 deletions
diff --git a/test/ng/httpBackendSpec.js b/test/ng/httpBackendSpec.js index faec5737..f39e83ea 100644 --- a/test/ng/httpBackendSpec.js +++ b/test/ng/httpBackendSpec.js @@ -363,7 +363,7 @@ describe('$httpBackend', function() { it('should convert 0 to 200 if content', function() { - $backend = createHttpBackend($browser, MockXhr, null, null, null, 'http'); + $backend = createHttpBackend($browser, MockXhr); $backend('GET', 'file:///whatever/index.html', null, callback); respond(0, 'SOME CONTENT'); @@ -373,19 +373,8 @@ describe('$httpBackend', function() { }); - it('should convert 0 to 200 if content - relative url', function() { - $backend = createHttpBackend($browser, MockXhr, null, null, null, 'file'); - - $backend('GET', '/whatever/index.html', null, callback); - respond(0, 'SOME CONTENT'); - - expect(callback).toHaveBeenCalled(); - expect(callback.mostRecentCall.args[0]).toBe(200); - }); - - it('should convert 0 to 404 if no content', function() { - $backend = createHttpBackend($browser, MockXhr, null, null, null, 'http'); + $backend = createHttpBackend($browser, MockXhr); $backend('GET', 'file:///whatever/index.html', null, callback); respond(0, ''); @@ -404,7 +393,6 @@ describe('$httpBackend', function() { expect(callback).toHaveBeenCalled(); expect(callback.mostRecentCall.args[0]).toBe(404); }); - }); }); diff --git a/test/ng/locationSpec.js b/test/ng/locationSpec.js index a60f1609..30f2f81a 100644 --- a/test/ng/locationSpec.js +++ b/test/ng/locationSpec.js @@ -695,69 +695,6 @@ describe('$location', function() { }); }); - - describe('SERVER_MATCH', function() { - - it('should parse basic url', function() { - var match = SERVER_MATCH.exec('http://www.angularjs.org/path?search#hash?x=x'); - - expect(match[1]).toBe('http'); - expect(match[3]).toBe('www.angularjs.org'); - }); - - - it('should parse file://', function() { - var match = SERVER_MATCH.exec('file:///Users/Shared/misko/work/angular.js/scenario/widgets.html'); - - expect(match[1]).toBe('file'); - expect(match[3]).toBe(''); - expect(match[5]).toBeFalsy(); - }); - - - it('should parse url with "-" in host', function() { - var match = SERVER_MATCH.exec('http://a-b1.c-d.09/path'); - - expect(match[1]).toBe('http'); - expect(match[3]).toBe('a-b1.c-d.09'); - expect(match[5]).toBeFalsy(); - }); - - - it('should parse host without "/" at the end', function() { - var match = SERVER_MATCH.exec('http://host.org'); - expect(match[3]).toBe('host.org'); - - match = SERVER_MATCH.exec('http://host.org#'); - expect(match[3]).toBe('host.org'); - - match = SERVER_MATCH.exec('http://host.org?'); - expect(match[3]).toBe('host.org'); - }); - - - it('should parse chrome extension urls', function() { - var match = SERVER_MATCH.exec('chrome-extension://jjcldkdmokihdaomalanmlohibnoplog/index.html?foo#bar'); - - expect(match[1]).toBe('chrome-extension'); - expect(match[3]).toBe('jjcldkdmokihdaomalanmlohibnoplog'); - }); - - it('should parse FFOS app:// urls', function() { - var match = SERVER_MATCH.exec('app://{d0419af1-8b42-41c5-96f4-ef4179e52315}/path'); - - expect(match[1]).toBe('app'); - expect(match[3]).toBe('{d0419af1-8b42-41c5-96f4-ef4179e52315}'); - expect(match[5]).toBeFalsy(); - expect(match[6]).toBe('/path'); - expect(match[8]).toBeFalsy(); - - match = SERVER_MATCH.exec('app://}foo{') - expect(match).toBe(null); - }); - }); - - describe('PATH_MATCH', function() { it('should parse just path', function() { @@ -1327,7 +1264,7 @@ describe('$location', function() { ); - it('should listen on click events on href and prevent browser default in hashbang mode', function() { + it('should listen on click events on href and prevent browser default in hashbang mode', function() { module(function() { return function($rootElement, $compile, $rootScope) { $rootElement.html('<a href="http://server/#/somePath">link</a>'); diff --git a/test/ng/urlUtilsSpec.js b/test/ng/urlUtilsSpec.js index 3c9bf847..18675ed8 100644 --- a/test/ng/urlUtilsSpec.js +++ b/test/ng/urlUtilsSpec.js @@ -1,29 +1,29 @@ 'use strict'; -describe('$$urlUtils', function() { +describe('urlUtils', function() { describe('parse', function() { - it('should normalize a relative url', inject(function($$urlUtils) { - expect($$urlUtils.resolve("foo")).toMatch(/^https?:\/\/[^/]+\/foo$/); - })); + it('should normalize a relative url', function () { + expect(urlResolve("foo").href).toMatch(/^https?:\/\/[^/]+\/foo$/); + }); - it('should parse relative URL into component pieces', inject(function($$urlUtils) { - var parsed = $$urlUtils.resolve("foo", true); + it('should parse relative URL into component pieces', function () { + var parsed = urlResolve("foo"); expect(parsed.href).toMatch(/https?:\/\//); - expect(parsed.protocol).toMatch(/^https?:/); + expect(parsed.protocol).toMatch(/^https?/); expect(parsed.host).not.toBe(""); expect(parsed.hostname).not.toBe(""); expect(parsed.pathname).not.toBe(""); - })); + }); }); describe('isSameOrigin', function() { - it('should support various combinations of urls - both string and parsed', inject(function($$urlUtils, $document) { + it('should support various combinations of urls - both string and parsed', inject(function($document) { function expectIsSameOrigin(url, expectedValue) { - expect($$urlUtils.isSameOrigin(url)).toBe(expectedValue); - expect($$urlUtils.isSameOrigin($$urlUtils.resolve(url, true))).toBe(expectedValue); + expect(urlIsSameOrigin(url)).toBe(expectedValue); + expect(urlIsSameOrigin(urlResolve(url, true))).toBe(expectedValue); } expectIsSameOrigin('path', true); - var origin = $$urlUtils.resolve($document[0].location.href, true); + var origin = urlResolve($document[0].location.href, true); expectIsSameOrigin('//' + origin.host + '/path', true); // Different domain. expectIsSameOrigin('http://example.com/path', false); |
